«Back to Home

Core Java

Topics

How To Set Path In Java

Set path in Java

We already know, set path is important, because when path is not set, it gives an error and our program is not run at that time. When we use javac and java commands, our system does not know about them. Due to this, it’s required to set the path.
 
Let’s see, how to set the path for Windows.
  1. We can set the path at temporary bases such as,

    First, open command prompt, copy path of jdk/bin directory and paste it in command prompt: set path=copied_path.

  2. It is waste of time, as it needs to set path every time. it’s good to set the path on permanent bases.

    Right click My Computer and its properties, advanced tab - environment variables - new tab - write path in variable name – copy the path bin from bin directory and write it in the variable value - ok.

    10

Setting path in other like Linux , UNIX.

Set the path in Linux, which is as same as setting the path in Windows. The only difference is that in Linux, we use export rather than set such as,
 
export PATH=$PATH:/home/jdk1.6.01/bin/.
 
Summary

Thus, we learnt, how to set the path on temporary basis and on permanent basis in Java. You also learnt, how to set the path in Linux, UNIX.