Setting java path

The main aim of setting path is to make available the following commands javac, java, javap (software) to the operating system. So that Operating system can find this executable files.

Note: If we save our java source file inside ' jdk/bin ' directory then path is not required to set becase all executable files (javac,java,javap etc) are availble inside bin directly . But If you are having your java file outside the jdk/bin folder, it is necessary to set path of JDK.

We can set path in 2 ways-
1) Temporary
2) Permanent

1) How to set Temporary Path of JDK in Windows.

To set the temporary path of JDK, you need to follow following steps:

  Copy the path of jdk/bin directory

  Open command prompt.

  write in command prompt: set path=copied_path.

set path=C:\Program Files\Java\jdk1.8.0_121\bin      : Press Enter

  That's it Temporary path is set to use.
Note : if you close the cmd then path will not work.
that is why we use parmanent path.

2) How to set Permanent Path of JDK in Windows

For setting the permanent path of JDK, you need to follow these steps:

This PC or MyComputer (right click on that) ---->properties----->Advanced--->
Environment Variables---->

User variables---New---->
variable name: path
Variable value  : C:\Program Files\Java\jdk1.8.0_121\bin;.;


Now the java is working good in your system. open the command prompt to check once and type:

C:>javac   : Press Enter
Now list of commands will be displayed

For example:

  1) Right click on ThisPC or MyComputer to open System properties.

  2) Now

  3)click on new tab of user variables

  3)Now, fill detail...

variable name: path
Variable value  : C:\ProgramFiles\Java\jdk1.8.0_121\bin;.;

  Now your permanent path is set.we can now execute any program of java from any drive.
To check type java -version

Setting Up the Path in Linux

Environment variable PATH should be set to point to where the Java binaries have been installed. Refer to your shell documentation, if you have trouble doing this. Example, if you use bash as your shell, then you would add the following line to the end of your '.bashrc: export PATH = /path/to/java:$PATH'

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

woman avatar