The path is the most important environment variable of the Java environment which is used to locate the JDK packages that are used to convert the java source code into the machine-readable binary format.
Tools like javac and java can be used by setting the path. When you save your file in the java directory i.e where java is installed, it is not necessary to set a path. But if you are saving your file outside the directory, it is fairly necessary to set the path beforehand.
There are two methods to set the path.
-
Temporary path
-
Permanent path
Temporary path of JDK
It is very easy to set the temporary path of JDK. Follow the following steps to set the path.
-
Open the terminal or command prompt
-
Go to the path where the JDK/bin directory has been saved
-
Copy the path
-
Enter the following command in the command prompt
This will set the temporary path of JDK.
Permanent Path of JDK
To set the permanent path of the JDK on your system, follow the steps below.
- Open System settings and go to advanced system settings.
-
Click on the environment variables in the tab.
-
Go to user variables and click on new.
-
Add the variable name as ‘path’.
-
Copy the path of the JDK bin directory.
-
Click ok.