How to set path in Java?

By | September 29, 2021

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

Vamware

Graph 1

Permanent JDK path setup

You can follow the below steps to set the path permanently-

Vamware
  • Right-click My computer for the setting.Step 2
  • Select Advanced tab -> select environment variables -> open new tab for user variableStep 3
  • Use ‘path’ for the variable name and copied path for the variable value.Step 4
  • 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.

export PATH=$PATH:/home/jdk1.6.01/bin/

People are also reading:

Leave a Reply

Your email address will not be published. Required fields are marked *