Ubuntu – How to set default Java version

javasoftware installation

I followed all the instructions stated at this question, but am encountering some problems with the last part of it.

I actually have version 6.22 of java and would like to update to version 6.30.

So after moving the extracted directory java-6-oracle into /usr/lib/jvm I do not know what to do, since the script that is pointed out in the answer above updates from java 5 to java 6.

For sake of clearness here is output if I do an ls in dir /usr/lib/jvm:

$ ls -l /usr/lib/jvm
total 8 
lrwxrwxrwx  1 root root   14 2011-07-12 15:18 default-java -> java-6-openjdk
lrwxrwxrwx  1 root root   14 2011-07-12 12:19 java-1.6.0-openjdk -> java-6-openjdk 
drwxr-xr-x 10 root root 4096 2012-04-12 12:06 java-6.31-oracle 
drwxr-xr-x  7 root root 4096 2012-02-24 14:43 java-6-openjdk

What should I do now?


Under the suggestion of @fossfreedom I ran the script anyway and actually it updated the java version.

In fact if I run command java -version output will be the following:

$ java -version
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b04)
Java HotSpot(TM) Server VM (build 20.6-b01, mixed mode)

There is still a problem, if Irun javac -version it gives me the old version installed:

$ javac -version
javac 1.6.0_22

And if I use the tester at this link it will tell me that version is

Java Version 1.6.0_22 from Sun Microsystems Inc.

What's going wrong?

It seems that Java Runtime Environment has updated, but Java Compiler and Java plugin for browser have not.

How can I update them?


sudo update-alternatives --config java will return following output

$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                      Priority   Status
* 0            /usr/lib/jvm/java-6.31-oracle/bin/java     1062      auto mode
  1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-6.31-oracle/bin/java     1062      manual mode

Press enter to keep the current choice[*], or type selection number:

these makes sense with the fact that JRE is correctly updated to version 6.31, issues are on Java Compiler and Java browser plugin.

Any ideas?

Best Answer

Re your first question:

possibly you may be confusing that the webupd8 script is 0.5b. That is the version of the script - it doesnt refer to the java version.

Further to the setting of the javac version.

I suspect you need to explicitly give the path of the javac compiler


sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java-6.31-oracle/bin/javac" 1

followed by:

sudo update-alternatives --config javac

With regards to setting up the java chrome plugin.

The master question:

How do I install Oracle JDK 6?

includes this information - since your folder structure is slightly different your link command should be:

ln -s /usr/lib/jvm/java-6.31-oracle/jre/lib/i386/libnpjp2.so ~/.mozilla/plugins/