Setting Environmental Variable in Linux

Environmental variables are set in Linux using “export” command at the command prompt.

They can be viewed using “set” command at the command prompt.

1. JAVA_HOME: Java SDK: (required for Tomcat, else you can set the path to your JDK in PATH variabl

# export JAVA_HOME=/usr/java/j2sdk1.4.2

2. CATALINA_HOME: Java SDK

# export CATALINA_HOME=/usr/local/jakarta-tomcat-4.0.5

3. CLASSPATH: Jars to be referenced

# export CLASSPATH=/opt/lib/alpha.jar:/opt/lib/beta.jar:/opt/lib/test.jar

Now if you want to add (append) more jars to CLASSPATH, you should use the following

command:

# export CLASSPATH=$CLASSPATH:/opt/lib/theta.jar

# export CLASSPATH=$CLASSPATH:$JAVA_HOME (appends JAVA_HOME to CLASSPATH)

4. PATH: Contains path of applications. If you want to add(append) /usr/local/jakarta-tomcat-4.0.5/bin to PATH (so that you can start and stop

tomcat from any directory) then

# export PATH=$CATALINA_HOME/bin:$PATH

Leave a Reply