How to set the environment variables for Java in Windows (the classpath)?
For Windows 7 users:
Right-click on My Computer, select Properties; Advanced; System Settings; Advanced; Environment Variables. Then find PATH in the second box and set the variable like in the picture below.
Set java Environment variable in Centos / Linux
/home/ vi .bashrc
export JAVA_HOME=/opt/oracle/product/java/jdk1.8.0_45
export PATH=$JAVA_HOME/bin:$PATH
java -version