Upgrade java version on solaris 10 SPARC

Hi Friends,

I am trying to upgrade my java version on solaris sparc machine. I have installed the o/s software from scratch and it came with some default java version. I want to install the newer version of java available on top of this machine.

I have already installed the latest version in my home directory (i.e)
jdk-6u26-solaris-sparcv9.sh jdk1.6.0_26

But still it is pointing to the old version. Can you please help me in creating symbolic links to point to the newer version.

Current java version as below:

java -version
java version "1.4.2_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02)
Java HotSpot(TM) Client VM (build 1.4.2_03-b02, mixed mode)

which java
/bin/java

ls -la /bin/java
lrwxrwxrwx   1 root     other         16 Aug 19 19:53 /bin/java -> ../java/bin/java


cd /usr/jdk
 >ls -la
total 16
drwxr-xr-x   4 root     bin          512 Sep 14 15:33 .
drwxr-xr-x  46 root     sys         1024 Sep 14 15:35 ..
lrwxrwxrwx   1 root     root          27 Sep 14 15:32 entsys-j2se -> /usr/jdk/instances/jdk1.5.0
drwxr-xr-x   3 root     bin          512 Aug 19 19:52 instances
lrwxrwxrwx   1 root     other          7 Aug 19 19:56 j2sdk1.4.2_22 -> ../j2se
lrwxrwxrwx   1 root     other         18 Sep 14 15:33 jdk1.5.0_04 -> instances/jdk1.5.0
lrwxrwxrwx   1 root     other         11 Sep 14 15:33 latest -> jdk1.5.0_04
drwxr-xr-x   8 root     bin          512 Aug 19 20:15 packages

It's Just a PATH problem edit your PATH variable to reflect the new full path to newer version of java have a look here

It was not clear, can you please explain clearly as i am new to unix..

I'll give you an example from one of my machines

So java bin points to /usr/java which points to /usr/jdk/jdk1.5.0_23

and in the JDK dir I have:

total 14
drwxr-xr-x   4 root     bin          512 Apr 17  2010 .
drwxr-xr-x  41 root     sys         1024 Sep 20 11:00 ..
drwxr-xr-x   3 root     bin          512 Jul  7  2006 instances
lrwxrwxrwx   1 root     other          7 Jul  7  2006 j2sdk1.4.2_08 -> ../j2se
lrwxrwxrwx   1 root     other         18 Apr 17  2010 jdk1.5.0_23 -> instances/jdk1.5.0
lrwxrwxrwx   1 root     other         11 Apr 17  2010 latest -> jdk1.5.0_23
drwxr-xr-x   7 root     bin          512 Jul  7  2006 packages

You could simply change /usr/java to point to /usr/jdk/latest. Because it is ebing changed when you update Java.

Hope this example helps you out.

I have followed the below procedure to point it to java 1.6

>ls -la /usr/java
lrwxrwxrwx 1 root other 15 Oct 19 2009 /usr/java -> jdk/jdk1.5.0_04

>cd /usr
>sudo rm -rf java
Password:

>sudo ln -s jdk/jdk1.6.0_27 java

>ls -la /usr/java
lrwxrwxrwx 1 root root 15 Sep 22 15:02 /usr/java -> jdk/jdk1.6.0_27

>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 do have below in my /usr/jdk directory

drwxr-xr-x 5 root bin 512 Sep 22 14:44 .
drwxr-xr-x 46 root sys 1024 Sep 22 15:13 ..
lrwxrwxrwx 1 root root 27 Oct 19 2009 entsys-j2se -> /usr/jdk/instances/jdk1.5.0
drwxr-xr-x 3 root bin 512 May 20 2009 instances
lrwxrwxrwx 1 root other 7 May 20 2009 j2sdk1.4.2_11 -> ../j2se
-rwxr-xr-x 1 root root 90228204 Sep 22 14:26 jdk-6u27-solaris-sparc.sh
-rwxr-xr-x 1 root root 12831072 Sep 22 14:26 jdk-6u27-solaris-sparcv9.sh
lrwxrwxrwx 1 root other 18 Oct 19 2009 jdk1.5.0_04 -> instances/jdk1.5.0
drwxr-xr-x 10 root root 512 Sep 22 14:45 jdk1.6.0_27
lrwxrwxrwx 1 root other 11 Oct 19 2009 latest -> jdk1.5.0_04
drwxr-xr-x 7 root bin 512 May 20 2009 packages

Please correct me if i am wrong.

I just can't figure out why your latest is not pointing to the latest ...

It seems good to me ... That's just one of the many ways to do it.

prash358 was right to:

Doing something like:

export PATH:/path/to/java;$PATH

Should have worked for the "current user".

Still, I think that my solution is more applicable to your case.

In my case how do i set the PATH variable? Can you please help me with this issue.
>which java
/bin/java

>ls -la /bin/java
lrwxrwxrwx 1 root other 16 May 25 00:07 /bin/java -> ../java/bin/java

>cd /usr
>ls -la java
lrwxrwxrwx 1 root root 15 Sep 22 03:05 java -> jdk/jdk1.5.0_04

Setting Path on Solaris and Linux
To find out if the java executable is in your PATH, execute:

% java -version

This will print the version of the java executable, if it can find it. If you get error java: Command not found. Then path is not properly set.

To find out which java executable the first one found in your PATH, execute:

% which java

Below are the steps to set the PATH permanently,
Note: We are here giving instructions for two most popular Shells on Linux and Solaris.
Please visit link below if you are using any other shells.
Path Setting Tutorial

For bash Shell:

Edit the startup file \(~/ .bashrc\)
Modify PATH variable:
PATH=/usr/local/jdk1.6.0/bin
export PATH
Save and close the file
Open new Terminal window
Verify the PATH is set properly
% java -version

For C Shell (csh):

Edit startup file \(~/ .cshrc\)
Set Path
set path=\(/usr/local/jdk1.6.0/bin \)
Save and Close the file
Open new Terminal window
Verify the PATH is set properly
% java -version