You are on page 1of 8

How to set path in java?

Setting Java Path in Windows


1. Go to the Search box and type advanced system settings in it.
Now click on the View advanced system settings.
2. Select the Advanced tab and then click
environment variables
3. In the system, variables click the New button. Now in the edit
system variable, type variable name as JAVA_PATH and variable
path as the path where the JDK folder is saved and click on OK
button Usually the path of the JDK file will be C:\Program Files\
Java\jdk1.8.0_60.
4. Now in the system variables go to the path
and click the edit button.
5. Click the New button.
6. Now add the following path:
%JAVA_HOME%\bin
Setting Java Path in Linux
• Open the terminal and enter the following command: 
• sudo nano /etc/environment.
• A file will be opened and add the following command to that file:
• JAVA_HOME = "YOUR_PATH".
• Replace YOUR_PATH with the JDK bin file path.
• Now restart your computer or virtual machine that you are using
(or) reload the file: source /etc/environment
• You can test the path by executing
• echo $JAVA_HOME
• If you get the output without any error, then you’ve set the path
correctly.
• If you get any errors, try repeating the procedure again.

You might also like