I just installed the latest java in /usr/jdk/jdk1.6.0_30
Now how do I make this java is the default java for the entire OS? As of now it is still using java 1.5
Thanks.
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.
Sign up to join this communityFound it...
$which java
/usr/bin/java
$ls -ld /usr/bin/java
lrwxrwxrwx 1 root other 16 Apr 8 12:41 /usr/bin/java -> ../java/bin/java
$rm /usr/bin/java
$ln -s /usr/jdk/jdk1.6.0_27/bin/java /usr/bin/java
$java -version
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) Server VM (build 20.2-b06, mixed mode)
I feel that just changing the symlink /usr/bin/java
is insufficient, because there's more than one Java symlink in /usr/bin:
# ls -l /usr/bin/java*
lrwxrwxrwx 1 root other 16 May 21 2015 /usr/bin/java -> ../java/bin/java
lrwxrwxrwx 1 root other 17 May 21 2015 /usr/bin/javac -> ../java/bin/javac
lrwxrwxrwx 1 root other 19 May 21 2015 /usr/bin/javadoc -> ../java/bin/javadoc
lrwxrwxrwx 1 root other 17 May 21 2015 /usr/bin/javah -> ../java/bin/javah
lrwxrwxrwx 1 root other 17 May 21 2015 /usr/bin/javap -> ../java/bin/javap
lrwxrwxrwx 1 root other 18 Jul 21 2015 /usr/bin/javaws -> ../java/bin/javaws
Instead, I would take advantage of the fact that /usr/java
is itself a symlink and replace it instead of 6+ others. Here is how I made JDK 8 the default:
# cd /usr
# rm java
# ln -s jdk/jdk1.8.0_121 java
# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)