Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple Java Enviroment on Linux

 
Kevin Fonner
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On my windows system I use batch files to setup different paths to use different jre's and jdk's. I set up a script on Linux but it doesn't seem to be adjusting my path. Does anybody know how to do this.
Here is my jdk122.sh
# Set Java Enviroment
JAVA_HOME=/usr/java/jdk122
export JAVA_HOME
CLASSPATH=.
export CLASSPATH
JDK_HOME=$JAVA_HOME
export JDK_HOME
JES_INSTALL_DIR=/home/kevin/java/jes2.0
export JES_INSTALL_DIR
JES_JAVA_HOME=$JAVA_HOME
export JES_JAVA_HOME
# Set Path
PATH=$JAVA_HOME/bin:$PATH
export PATH
 
Varun Narula
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
maybe you need to add the classpath variables too. the classpath currently has been set only for the current directory(.)
try adding $JAVA_HOME/jre/lib/rt.jar and tools.jar to your classpath
Hope that helps !
Varun Narula
 
Steve Deadsea
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only thing I can think of is to add quotes:
PATH="$JAVA_HOME/bin:$PATH"
export PATH
 
Guy Allard
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi - If you are invoking the script like:
jdk122.sh # it is in PATH
*or*
./jdk122.sh # it is not in PATH
then the shell forks and execs a new shell to run the script, which ends, and you are right back to where you started.
To properly set environment variables for the running shell, do:
. ./jdk122.sh
HTH, Guy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic