How to set default Java version?
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?
ADDED PART
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?
OTHER ADDED PART
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?
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
i.e.
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/
See this; run
sudo update-java-alternatives --list
to list off all the Java installations on a machine by name and directory, and then run
sudo update-java-alternatives --set [JDK/JRE name e.g. java-8-oracle]
to choose which JRE/JDK to use.
If you want to use different JDKs/JREs for each Java task, you can run update-alternatives to configure one java executable at a time; you can run
sudo update-alternatives --config java[Tab]
to see the Java commands that can be configured (java, javac, javah, javaws, etc). And then
sudo update-alternatives --config [javac|java|javadoc|etc.]
will associate that Java task/command to a particular JDK/JRE.
You may also need to set JAVA_HOME for some applications: from this answer you can use
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
for JREs, or
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:jre/bin/java::")
for JDKs.
I think you should take a look at the update-java-alternatives
command from the java-common
package and the *.jinfo
files used by it. With that you should be able to switch completely between java installations (regardless of JDK, JRE, ...).