How to downgrade Java. For example Java 7u72 to 7u67
Download
Go to official java download page, scroll down to the bottom of the page until you see Previous Releases. Click Download
Choose Java SE 7
on the next page and you will see web-page where you can choose specific Java version. If you unsure what to choose, choose Development Kit - it will cover all your needs
Now you will get this page. And you see something like screenshot below. Choose tar.gz
depending on your architecture, I highlighted two of them that fits Ubuntu:
Oracle may ask you to sign up before download
Installation
Now you have file jdk*.tar.gz
. Here is great manual about installing java. I took out the instruction and changed it a little bit.
-
Uncompress
.tar.gz
tar -xvf jdk*
The JDK package is extracted into jdk.xxx
directory. Check carefully this folder name, because we will use it the next step. I'm assuming that path to this new extracted folder is path_to_jdk_folder
and folder name is folder_name
, you should manually change it before executing commands below.
Usually it is:
path_to_jdk_folder - /home/c0rp/Downloads/jdk1.7.0
folder_name - jdk1.7.0
- Installing
Run sudo update-alternatives --list java
to check if you have configured java already.
$ sudo update-alternatives --list java
/usr/lib/jvm/jdk1.6.0_45_x586/bin/java
/usr/lib/jvm/jdk1.7.0_21/bin/java
/usr/lib/jvm/jdk1.8.0/bin/java
If it is saying update-alternatives: error: no alternatives for java
run this set of commands. Don't forget replace path_to_jdk_folder
and folder_name
:
sudo mkdir /usr/lib/jvm
sudo mv path_to_jdk_folder /usr/lib/jvm/folder_name
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/folder_name/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/folder_name/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/folder_name/bin/javaws" 1
sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
If there is no errors and your java list is not empty, run this set of commands. Don't forget replace path_to_jdk_folder
and folder_name
:
LNUM=$[$(update-alternatives --list java | wc -l) + 1]
sudo mv path_to_jdk_folder /usr/lib/jvm/folder_name
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/folder_name/bin/java" "$LNUM"
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/folder_name/bin/javac" "$LNUM"
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/folder_name/bin/javaws" "$LNUM"
-
Run
sudo update-alternatives --config java
You will see output similar to the one below - choose the number of new jdk1.7.0 (folder_name)
- for example 2
in this list (unless you have have never installed Java in your computer in which case a sentence saying There is nothing to configure
will appear):
$ sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode
1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
2 /usr/lib/jvm/jdk1.7.0/bin/java 1 manual mode
* 3 /usr/lib/jvm/jdk1.8.0/bin/java 1 manual mode
Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.8.0/bin/java to provide /usr/bin/java (java) in manual mode
Repeat the above for:
sudo update-alternatives --config javac
sudo update-alternatives --config javaws
Check installation
java -version