Tuesday, 6 September 2011

Setting JAVA_HOME and PATH variables in Linux

JAVA_HOME

JAVA_HOME is the directory where your Java JDK is installed. To set this; In a Linux Terminal use the export command to set the variable.

JAVA_HOME=<path-to-java>

If your path is set to /usr/java/jdk1.6.0_24/bin/java, set it as follows:

export JAVA_HOME=/usr/java/jdk1.6.0_24/bin/java

PATH

Set this variable to run Java commands without referencing the absolute location of Java every time i.e. javac MyClass.java rather than /usr/java/jdk1.6.0_24/bin/javac MyClass.java. To do this, also in a terminal append the <path-to-java> to the PATH variable using the export command.

PATH=$PATH:/usr/java/jdk1.6.0_24/bin

To see the changes use the echo command.

echo $JAVA_HOME
echo $PATH

No comments:

Post a Comment