Reference: https://docs.oracle.com/javase/tutorial/essential/environment/paths.html
The Java PATH environment variable can be seen from the documentation in the Orcle official website:
Java PATH environment variable is java in the execution of the command to find Javac the location of the program (expand the other applications should also be the case, the resource environment variable is an application to their own needs of the resources, where) {One is the location of the program, one is where the resource is located}.
The PATH
environment variable is a series of directories separated by semicolons ( ;
). Microsoft Windows looks PATH
for programs in the directories on order, from left to right. You should has only one bin
directory for the JDK with the path at a time (those following the first is ignored), so if One is already present and you can update that particular entry.
The following is an example of a PATH
environment variable:
C:\Java\jdk1.7.0\bin; C:\Windows\System32\; C:\Windows\; C:\Windows\System32\Wbem
Windows environment variables are used; Separated
Setting method: (original)
Windows XP
- Select Start, select Control Panel. Double click System, and select the Advanced tab.
- Click Environment Variables. In the section System Variables, find the
PATH
environment variable and select it. Click Edit. If PATH
The environment variable does not exist, click New
.
- In the Edit system Variable (or New System Variable) window, specify the value of the
PATH
environ ment variable. Click OK. Close all remaining windows by clicking OK.
Windows Vista:
- From the desktop, right click the My computer icon.
- Choose Properties from the context menu.
- Click the Advanced tab (Advancedsystem Settings link in Vista).
- Click Environment Variables. In the section System Variables, find the
PATH
environment variable and select it. Click Edit. If PATH
The environment variable does not exist, click New
.
- In the Edit system Variable (or New System Variable) window, specify the value of the
PATH
environ ment variable. Click OK. Close all remaining windows by clicking OK.
Windows 7:
- From the desktop, right click the computer icon.
- Choose Properties from the context menu.
- Click the Advanced system settings link.
- Click Environment Variables. In the section System Variables, find the
PATH
environment variable and select it. Click Edit. If PATH
The environment variable does not exist, click New
.
- In the Edit system Variable (or New System Variable) window, specify the value of the
PATH
environ ment variable. Click OK. Close all remaining windows by clicking OK.
Note:You could see a
PATH
environment variable similar to the following when editing it from the Control Panel:
%java_home%\bin;%systemroot%\system32;%systemroot%;%systemroot%\system32\wbem
Variables enclosed in percentage signs (
%
) is existing environment variables. If One of these variables is listed in the
Environment VariablesWindow from the Control Panel (such as
JAVA_HOME
), then you can edit its value. If it does not appear and then it was a special environment variable that the operating system have defined. For example,
SystemRoot
is the location of the Microsoft Windows system folder. To obtain the value of a environment variable, enter the following at a command prompt. (This example obtains the value of the
SystemRoot
environment variable):
Echo%SystemRoot%
Update the PATH Variable (Solaris and Linux)
You can run the JDK just fine without setting PATH
the variable, or you can optionally set it as a convenience. However, you should set the ' path variable if you want to being able to run ' the executables ( javac
,, java
javadoc
, and so on) F Rom any directory without have to type the full path of the command. If you don't set the PATH
variable, you need to specify the full path to the executable every time you run it, such as:
%/usr/local/jdk1.7.0/bin/javac Myclass.java
To find out if the path is properly set, execute:
% java-version
This would print java
the version of the tool, if it can find it. If The version is an old or you get the error Java:command not foundand then the path was not properly set.
To set the path permanently, set the path in your startup file.
For C Shell ( csh
), edit the Startup file (~/.cshrc
):
Set path= (/usr/local/jdk1.7.0/bin $path)
bash
for, edit the startup file ( ~/.bashrc
):
Path=/usr/local/jdk1.7.0/bin: $PATHexport PATH
ksh
for, the startup file was named by the environment variable, ENV
. To set the path:
Path=/usr/local/jdk1.7.0/bin: $PATHexport PATH
sh
for, edit the profile file ( ~/.profile
):
Path=/usr/local/jdk1.7.0/bin: $PATHexport PATH
Then load the startup file and verify, the path is set by repeating the java
command:
For C Shell ( csh
):
% Source ~/.cshrc% java-version
For ksh
, bash
, or sh
:
% . /.profile% java-version
What is a Java PATH environment variable