Tuesday, June 23, 2009

Changing JAVA HOME on Solaris 10

I'm trying to install Sun Java System Calendar Server 7 Beta. It has a pre-requisite for JDK 6. 

We know that default Solaris 10 has JDK 5 pre-installed. So, I went ahead to download JDK 6 from here.

From my experience, I know that all JDK installation on Solaris can be found in /usr/jdk. So I unpacked the JDK 6 binary in the same directory.

bash-3.00# cd /usr/jdk/
bash-3.00# ./jdk-6u14-solaris-i586.sh 

Well, after unpacking, we need to make sure that we are calling the latest JDK system-wide. Otherwise, you'll see the following:

bash-3.00# java -version
java version "1.5.0_14"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)
Java HotSpot(TM) Client VM (build 1.5.0_14-b03, mixed mode, sharing)
bash-3.00# javac -version
javac 1.5.0_14

This is not what we want!

So here we go: I'll try to find out the exact location of the various Java related commands.

bash-3.00# ls -al /usr/bin/java*
lrwxrwxrwx   1 root     other         16 Jul  3  2008 /usr/bin/java -> ../java/bin/java
lrwxrwxrwx   1 root     other         17 Jul  3  2008 /usr/bin/javac -> ../java/bin/javac
lrwxrwxrwx   1 root     other         19 Jul  3  2008 /usr/bin/javadoc -> ../java/bin/javadoc
lrwxrwxrwx   1 root     other         17 Jul  3  2008 /usr/bin/javah -> ../java/bin/javah
lrwxrwxrwx   1 root     other         17 Jul  3  2008 /usr/bin/javap -> ../java/bin/javap
lrwxrwxrwx   1 root     other         18 Jul  3  2008 /usr/bin/javaws -> ../java/bin/javaws

bash-3.00# ls -al /usr/java   
lrwxrwxrwx   1 root     other         15 Jul  3  2008 /usr/java -> jdk/jdk1.5.0_14

So, it's simple! Remove the existing symbolic link of "usr/java" from JDK 1.5 to 1.6.

bash-3.00# rm /usr/java
bash-3.00# ln -s jdk/jdk1.6.0_14 /usr/java

bash-3.00# java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)
bash-3.00# javac -version
javac 1.6.0_14

I also did not feel easy with "latest" directory symbolic-linked to JDK 1.5 in "/usr/jdk". So I went ahead to replace it with JDK 1.6, even though I knew nothing will break.

bash-3.00# cd /usr/jdk
bash-3.00# ls -altr
total 16
lrwxrwxrwx   1 root     other          7 Jul  3  2008 j2sdk1.4.2_16 -> ../j2se
drwxr-xr-x   3 root     bin          512 Jul  3  2008 instances
lrwxrwxrwx   1 root     other         18 Jul  3  2008 jdk1.5.0_14 -> instances/jdk1.5.0
lrwxrwxrwx   1 root     other         11 Jul  3  2008 latest -> jdk1.5.0_14
drwxr-xr-x   8 root     bin          512 Jul  3  2008 packages
drwxrwxr-x  10 root     root         512 Jun 23 13:12 jdk1.6.0_14
drwxr-xr-x   5 root     bin          512 Jun 23 13:15 .
drwxr-xr-x  40 root     sys         1024 Jun 23 13:17 ..

bash-3.00# rm latest
bash-3.00# ln -s jdk1.6.0_14 latest

bash-3.00# ls -altr
total 16
lrwxrwxrwx   1 root     other          7 Jul  3  2008 j2sdk1.4.2_16 -> ../j2se
drwxr-xr-x   3 root     bin          512 Jul  3  2008 instances
lrwxrwxrwx   1 root     other         18 Jul  3  2008 jdk1.5.0_14 -> instances/jdk1.5.0
drwxr-xr-x   8 root     bin          512 Jul  3  2008 packages
drwxrwxr-x  10 root     root         512 Jun 23 13:12 jdk1.6.0_14
drwxr-xr-x  40 root     sys         1024 Jun 23 13:17 ..
lrwxrwxrwx   1 root     root          11 Jun 23 13:24 latest -> jdk1.6.0_14
drwxr-xr-x   5 root     bin          512 Jun 23 13:24 .

No comments:

Post a Comment