How to set path in Java


The path is required to be set for using tools such as javac, java etc. If you are saving the java source file inside the jdk/bin directory, path is not required to be set because all the tools will be available in the current directory.

But If you are having your java file outside the jdk/bin folder, it is necessary to set path of JDK.

There are 2 ways to set java path:

  1. Temporary
  2. Permanent

1) How to set Temporary Path of JDK in Windows

To set the temporary path of JDK, you need to follow following steps:

  1. First you create your folder in any drive.
  2. Open notepad editor.
  3. Write following path.

For Example:

set path=C:\Windows\System32;d:\jdk1.6.0\bin;

bat1

 

4.    Then save this file with .bat extension in your folder.

5.    Now open command prompt and execute the bat file.

for example.

bat2

 

2) How to set Permanent Path of JDK in Windows

For setting the permanent path of JDK, you need to follow these steps:
• 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.

bat3

 

 

 

2.click on advance tab.

bat4

 

 

 

 

 

 

 

 

 

 

 

 

3.click on environment variables.

bat5

 

 

 

 

 

 

 

 

 

 

 

 

4.click on new tab of user variable.

bat6

 

 

 

 

 

 

 

 

 

 

5.write path in variable name.

bat7

 

 

 

 

 

 

 

 

 

 

 

6. Copy the path of bin folder.

bat97.Paste path of bin folder in variable value.

bat10

 

 

 

 

 

 

 

 

 

 

 

 

 

8.click on ok button.

bat11

 

 

 

 

 

 

 

 

 

 

 

 

9.click on ok button.

bat12

 

 

 

 

 

 

 

 

 

 

 

 

Now path is set permanent.Now you can execute any java program from any drive.

Comments are closed.