Wednesday, March 12, 2014

setting persistant system wide environment variables


The folder /etc/profile.d/ is the recommended place to add customizations to the system profile.
do not edit /etc/profile  rather add files in the /etc/profile.d folder

For example, when installing the oracle JDK, you might need to set the JAVA_HOME and JRE_HOME environment variables.

Create a new file called java.sh
vim /etc/profile.d/java.sh

Within this file, initialize the necessary environment variables
export JRE_HOME=/usr/java/jdk1.7/jre
export PATH=$PATH:$JRE_HOME/bin

export JAVA_HOME=/usr/java/jdk1.7
export JAVA_PATH=$JAVA_HOME

export PATH=$PATH:$JAVA_HOME/bin

save the file.

every time you reboot the environment variable will be loaded system wide..

No comments: