In the past, to make an environment variable perminant, I would append to the /etc/profile file the environment variable for JAVA_HOME for example and update the PATH. While this does work, it has recently come to my attention that a more appropriate and easier method exists which does not involve editing the /etc/profile file.
For this example, the environment variable, JAVA_HOME will be created for Java. Navigate to the /etc/profile.d directory. Use vim or your favorite editor to create a file called java.sh. With the full path, the file is /etc/profile.d/java.sh.
This Java was installed using yum. Your path may likely vary. Add the following content to the java.sh file and save it. Done.
export JRE_HOME=/usr/lib/jvm/java-1.6.0-openjdk-126.96.36.199.x86_64/jre export PATH=$PATH:$JRE_HOME/bin export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-188.8.131.52.x86_64 export JAVA_PATH=$JAVA_HOME export PATH=$PATH:$JAVA_HOME/bin
To avoid restarting the server, issue the following command to start the script.
Check your path
# echo $JAVA_HOME