This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Multiple Java Enviroment on Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Multiple Java Enviroment on Linux" Watch "Multiple Java Enviroment on Linux" New topic
Author

Multiple Java Enviroment on Linux

Kevin Fonner
Greenhorn

Joined: Sep 20, 2001
Posts: 21
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

Joined: Nov 19, 2001
Posts: 90
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


There are only 10 types of people in this world; those who understand binary and those who dont<p>Varun Narula <br />SCJP, SCWCD, IBM-486 (UML)
Steve Deadsea
Ranch Hand

Joined: Dec 03, 2001
Posts: 125
The only thing I can think of is to add quotes:
PATH="$JAVA_HOME/bin:$PATH"
export PATH
Guy Allard
Ranch Hand

Joined: Nov 24, 2000
Posts: 776
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Multiple Java Enviroment on Linux
 
Similar Threads
setting system envarioment variables in java
Installin Java on Linux
Java 1.5 on mac
Installing Java on Linux
Default CLASSPATH for multi-user systems