How To Set Path in Java
How To Set Path in Java
If you are saving the Java source file inside the JDK/bin directory, the path is not required to be set
because all the tools will be available in the current directory.
However, if you have your Java file outside the JDK/bin folder, it is necessary to set the path of JDK.
1. Temporary
2. Permanent
For Example:
https://www.javatpoint.com/how-to-set-path-in-java 2/12
7/20/23, 11:12 PM How to Set Path in Java - Javatpoint
Go to MyComputer properties -> advanced tab -> environment variables -> new tab of user
variable -> write path in variable name -> write path of bin folder in variable value -> ok ->
ok -> ok
For Example:
1) Go to MyComputer properties
https://www.javatpoint.com/how-to-set-path-in-java 3/12
7/20/23, 11:12 PM How to Set Path in Java - Javatpoint
https://www.javatpoint.com/how-to-set-path-in-java 4/12
7/20/23, 11:12 PM How to Set Path in Java - Javatpoint
https://www.javatpoint.com/how-to-set-path-in-java 5/12
7/20/23, 11:12 PM How to Set Path in Java - Javatpoint
8) Click on ok button
9) Click on ok button
https://www.javatpoint.com/how-to-set-path-in-java 7/12
7/20/23, 11:12 PM How to Set Path in Java - Javatpoint
Now your permanent path is set. You can now execute any program of java from any drive.
Setting path in Linux OS is the same as setting the path in the Windows OS. But, here we use the
export tool rather than set. Let's see how to set path in Linux OS:
export PATH=$PATH:/home/jdk1.6.01/bin/
Here, we have installed the JDK in the home directory under Root (/home).
https://www.javatpoint.com/how-to-set-path-in-java 8/12