The easy way to do it is to use symlinks for the Java location.  For
example, I used to create /opt/ibmjava which always pointed to the
latest version of IBM's JDK.  Then my PATH just had /opt/ibmjava/bin
and I had an entry in my bashrc for JAVA_HOME=/opt/ibmjava.

The other thing to look at is that some distributions have nice little
tools to manage /etc/alternatives (Ubuntu in particular has
update-alternatives that will update all of the symlinks and path
options for you).

ks


On 4/13/07, McKown, John <[EMAIL PROTECTED]> wrote:
My mind is dying from sinuses. What I would like to do is change a
subdirectory mentioned in the PATH variable with a different value. In
particular, I have multiple JAVA releases installed. In /etc/profile, I
set JAVA_HOME to the default directory and put JAVA_HOME/bin on the
PATH. I would like to write a simple shell script which changes the
current value of JAVA_HOME to a different value (easy) and change the
JAVA_HOME/bin portion of the PATH to the "new" one, then invoke java.
Something like:

#!/bin/sh
newhome="/java160"
if [ ! -z $JAVA_HOME ]; then
PATH=$(...)
fi
export JAVA_HOME=${newhome}
export PATH={$PATH}:${newhome}/bin

What I want in the ... portion is to erase ${JAVA_HOME}/bin along with
appropriate semi-colon separator (i.e. trailing if JAVA_HOME/bin is the
first on the list, otherwise leading).

I was thinking of something like sed, but just cannot get my brain to
work very well today.

Should I just give up and not set a default, but create a "java" shell
script to invoke java? Oh, and I guess the same for javac, but that is
not as critical for me.

What I really wish that I could do would be to "source" some file which
would do the same so that the "default" java for that user would be
changed until some over "java selection" script was sourced. Is this
possible?

Thanks for any ideas. Maybe if I get over this sinus attack next week, I
may figure it out myself.

--
John McKown
Senior Systems Programmer
HealthMarkets
Keeping the Promise of Affordable Coverage
Administrative Services Group
Information Technology


----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to