Main Menu



You are here: Home
Installing Specific Versions of Java on Ubuntu PDF Print E-mail
Written by Josh B   
Wednesday, 11 May 2011 12:31

Tags: java | ubuntu

While its very easy to install the standard versions of Java in Ubuntu, some times you will want to install a specific version of Java. This makes tasks like deployment and testing much easier since you know exactly the version of Java you are coding against. To do this, use the following steps...

 

For example, I wanted to JDK 1.6.0.25. First I had to go to Oracle (not Sun anymore) and download the installer. I then extracted it and put the directory in /usr/lib/jvm/ . For me, once I had unpacked the directory, the new JDK was in a directory called jdk1.6.0_25. For completeness, I rename this to java-6-sun4josh-1.6.0.24. NB: I added the "4josh" part so it wouldn't get affected by any future updates.

sudo mv ~/Downloads/jdk1.6.0_25 /usr/lib/jvm
cd /usr/lib/jvm
sudo mv jdk1.6.0_25 java-6-sun4josh-1.6.0.25

In /usr/lib/jvm there are files like .java-1.5.0-sun.jinfo and .java-6-sun.jinfo . We need to make one ourselves :

sudo cp .java-6-sun.jinfo .java-6-sun4josh-1.6.0.25.jinfo

Now edit it using:

sudo gedit .java-6-sun4josh-1.6.0.25.jinfo

You will need to change the name and alias as well as the paths to point your version of java.

Download the update-java script from http://webupd8.googlecode.com/files/update-java and run it with:

chmod 755 update-java
sudo ./update-java

This should pick up your new version of Java.

Now check with:

java -version

Eg:

Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)
Last Updated on Wednesday, 11 May 2011 12:40
 

Add comment


Security code
Refresh

Joomla! Template by Red Evolution - Joomla Web Design