Overriding PATH

Hello,

I'm using Sun solaris .

I'm trying to override the environmental variable in my script, however when I execute the script, the PATH whatever being set in .profile is taking precedence.

I have done the sanity checks like order of my entry in path, permissions for the user etc.,

To be precise, I have two versions of Java in my server , my .profile refers to java1.4, however for a specific application which is trigerred from bash shell script,I want to use Java1.6.

#!/bin/bash
JAVA_HOME=/export/home/def/java/jre
export JAVA_HOME

PATH=$JAVA_HOME/bin/sparcv9:$PATH
export PATH

LD_LIBRARY_PATH=$JAVA_HOME/lib/sparcv9:$JAVA_HOME/lib/sparcv9/server:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

CASSPATH=/export/home/def/Scripts/XL/:/export/home/def/Scripts/XL/jar/bin/xalan.jar:/export/home/def/Scripts/XL/jar/bin/xercesl.jar;
export CLASSPATH


echo "java home is ----> $JAVA_HOME"
echo "\n"
echo "java path is ----> $PATH"
echo "\n"
echo "java LD_LIB is  ----> $LD_LIBRARY_PATH"
echo "\n"
echo "java classpath  is  ----> $CLASSPATH"

echo "\n"
echo "java instance ----->"`which java`
echo "\n"
echo "java version ----->"`java -version`

java app1 start

I'm epecting this script to calll the java instance set in JAVA_HOME, however it still calls the /usr/bin/java (being set in .profile).
However if I change the values of environmental variables provided above in .profile, then I'm able to call the appropriate java version.
I don't wanna apply this change for the entire user but for just the session.
Can I not override environmental variables for a session alone ?

Thanks

You must have an alias set for java which points to /usr/bin/java or whatever: to check try:

alias | grep java
1 Like