If the Java source file is inside the jdk/bin folder,path is not required to be set because the tools like javac,java are inside the current folder.
But if the java source file is outside the jdk/bin folder,path is required to be set in order to execute java source file.
There are two ways to set java path:
- Temporary
- Permanent
- Setting Temporary Java Path:
To set temporary java path:
- Open command prompt
- Copy the path of jdk/bin directory
- Write in command prompt:SET PATH=copied_path
For example:
SET PATH=C:\Program Files\Java\jdk1.7.0_79\bin
To set permanent java path:
- Go to MyPC properties
- Click on Advanced system settings
- Click on Environment Variables
- Click on New tab of User variables
- Assign value Gfg_path to Variable name:
- Copy the path of bin folder
- Paste path of bin folder in Variable value:
- Click on OK button
- Click on OK button
In this way Temporary and Permanent Path for Java can be set in Windows.