What is a Java PATH environment variable

Source: Internet
Author: User

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

    1. Select Start, select Control Panel. Double click System, and select the Advanced tab.
    2. 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 .
    3. 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:

    1. From the desktop, right click the My computer icon.
    2. Choose Properties from the context menu.
    3. Click the Advanced tab (Advancedsystem Settings link in Vista).
    4. 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 .
    5. 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:

    1. From the desktop, right click the computer icon.
    2. Choose Properties from the context menu.
    3. Click the Advanced system settings link.
    4. 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 .
    5. 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 PATHenvironment 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, SystemRootis 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 SystemRootenvironment 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)

bashfor, edit the startup file ( ~/.bashrc ):

Path=/usr/local/jdk1.7.0/bin: $PATHexport PATH

kshfor, the startup file was named by the environment variable, ENV . To set the path:

Path=/usr/local/jdk1.7.0/bin: $PATHexport PATH

shfor, 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.