Search code examples
sunos.profile

Getting the Java Version I want in a SunOS account


I have an account on a Unix server. I can't get it to point to the version of Java I want when I am in BASH.

The version of Unix is:

SunOS 5.10 Generic January 2005 

This is what I have in my .profile:

#====================================================================
#   set the environment
#====================================================================

ANT_HOME=/apps1/apache-ant-1.8.4
export ANT_HOME

#  $PATH:/user1/acme21 needs to be included to make anything work
PATH=.:/usr/jdk/instances/jdk1.6.0_24:$ANT_HOME/bin:$PATH:/user1/acme21
export PATH

JAVA_HOME=/usr/jdk/instances/jdk1.6.0_24
export JAVA_HOME

CLASSPATH=.:/user1/sterus01/TestProgramsLib/mail.jar:/user1/sterus01/TestProgramsLib/activation.jar:/user1/sterus01/TestProgramsLib/log4j-1.2.16.jar:/user1/sterus01/TestProgramsLib/mail.jar:ojdbc14.jar
export CLASSPATH

env | grep DIS

# Use the bash shell, get many conveniences
bash

When I run echo $JAVA_HOME and echo $PATH I get

bash-3.00$ echo $JAVA_HOME
/usr/jdk/instances/jdk1.6.0_24
bash-3.00$

and

bash-3.00$ echo $PATH
.:/usr/jdk/instances/jdk1.6.0_24:/apps1/apache-ant-1.8.4/bin:/usr/bin:/usr/local/bin:/usr/ccs/bin:/usr/bin:/usr/sbin:/etc:/usr/ucb:/usr/local/sudo:/usr/local/sbin:/user1/acme21
bash-3.00$

Yet "which javac" reveals:

bash-3.00$ which javac
/usr/bin/javac
bash-3.00$

and "which java" reveals:

bash-3.00$ which java
/usr/bin/java
bash-3.00$

Is there anything I can do to get it to point to the Java version I specified in my .profile file?

Thanks in advance Happy Holidays Steve


Solution

  • I suspect this:

    PATH=.:/usr/jdk/instances/jdk1.6.0_24
    

    isn't right, and you need instead

    PATH=.:/usr/jdk/instances/jdk1.6.0_24/bin
    

    to pick up the binary directory within that Java installation.

    p.s. I wouldn't put the current directory (.) in your PATH. Otherwise someone can substitute a trojan-like program (e.g. a substitute for ls) in a directory. You'll pick that up when you cd into the containing directory and type ls (there's an entertaining story relating to this in the Unix Power Tools book)