-1

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

Steve
  • 3,127
  • 14
  • 56
  • 96
  • I do not agree with my question being closed and voted down. I do not agree because I think getting the version of Java I want set up in a Unix account is about programming and is about software development. That is what I was trying to do when I ran into the problem that led to me creating the post. No disrespect. I value the moderation at stackoverflow. It is nice to ask a question without getting slammed, like on Usenet. – Steve Apr 18 '13 at 18:29

2 Answers2

1

Are you sure your java and javac executables are in /usr/jdk/instances/jdk1.6.0_24 ? Perhaps they are in /usr/jdk/instances/jdk1.6.0_24/bin/.

piokuc
  • 25,594
  • 11
  • 72
  • 102
0

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)

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
  • That was it! Thanks. Thaks for the tip about removing the current directory from the path as well. – Steve Dec 21 '12 at 15:36