To use the java tools like javac you have to set the path to access the functionality. If you are using the directory JDK/bin for your code then you do not need to set the path as all the tools will be available in that directory. But if you are saving your java source code outside the JDK directory then you have to set the path.
You can set the path either temporary or permanent.
Temporary JDK path setup in Windows
You can follow the below steps to set the path temporarily-
- Open a command prompt from the start menu.
- Copy the JDK/bin folder path
- Then paste the copied path using below command-
Set path= copied_path
set path=C:\Program Files\Java\jdk1.6.0_23\bin
Permanent JDK path setup
You can follow the below steps to set the path permanently-
- Right-click My computer for the setting.
- Select Advanced tab -> select environment variables -> open new tab for user variable
- Use ‘path’ for the variable name and copied path for the variable value.
- Then click ok
How to set the Java path in Linux
You can set the path in Linux in the same way as we did in the Windows. But in Linux, we use the export command rather than the set command.
People are also reading: