How to Set Path in Java?

    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 the below command:

    Set path= copied_path set path=C:\Program Files\Java\jdk1.6.0_23\bin Graph 1

    Permanent JDK Path Setup

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

    • Right-click My computer for the setting. Step 2
    • Select Advanced tab -> select environment variables -> open new tab for user variable Step 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 Windows. But in Linux, we use the export command rather than the set command. export PATH=$PATH:/home/jdk1.6.01/bin/


    In this tutorial, we have discussed how to set a temporary and permanent Java path in Windows. Also, we have discussed setting the Java path in Linux. If you have any doubts or queries, feel free to share them with us in the comments section below. People are also reading: