Setting the JAVA_HOME

Setting the JAVA_HOME in Windows

You must follow these steps to set JAVA_HOME variable on your Windows system.

Right-click the My Computer icon on your desktop and select Properties. Click Advanced system settings link. Click the Advanced tab. Click the Environment Variables button. Under System Variables, click New. Enter the variable name as JAVA_HOME Enter the variable value as the installation path for the Java Development Kit as something like this C:\Program Files\Java\jdk1.8.0_51

Click OK.

Under System Variables, select Path system variable Click Edit. Scroll to the beginning of the Variable value and insert %JAVA_HOME%\bin;

Click OK.

Click OK.

Click Apply.

If the changes do not take effect restart Windows.

Setting the JAVA_HOME in Linux

Launch Terminal by pressing Ctrl+Alt+T on your keyboard.

Enter the following command:$ gksudo gedit /etc/environment

Depending on where you installed your Java, you will need to provide the full path. For this example, I installed Oracle JDK 7 in the /usr/lib/jvm/java-7-oracle directory. Scroll to the end of the file and enter the following:JAVA_HOME=/usr/lib/jvm/java-7-oracle export JAVA_HOME

Save your file and exit gedit.

Lastly, reload the system PATH with the following command:$ . /etc/environment The above method will save you the hassle in having to run the commands every time you log in to your computer.

Setting the JAVA_HOME in Mac

1. Mac OSX 10.5 or later

In Mac OSX 10.5 or later, Apple recommends to set the $JAVA_HOME variable to /usr/libexec/java_home, just export $JAVA_HOME in file ~/. bash_profile or ~/.profile.