Monday, December 17, 2012

Set Java Path in linux


SET JAVA PATH IN LINUX:

Set JAVA_HOME as follows using syntax export JAVA_HOME=<path-to-java>. If your path is set to /usr/java/jdk1.5.0_07/bin/java, set it as follows:

$ export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java

Set PATH as follows:
$export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
Save and close the file. Just logout and login back to see new changes:
$ echo $JAVA_HOME
$ echo $PATH

Tip: Use the following command to find out exact path to which java executable under UNIX / Linux:
$ which java

Set JAVA_HOME / PATH for all user


You need to setup global config in /etc/profile OR /etc/bash.bashrc file for all users:

# vi /etc/profile
Next setup PATH / JAVA_PATH variables as follows:

export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin

No comments:

Post a Comment