banner



How To Set Path In Windows 7 For Java

This department explains how to use the PATH and CLASSPATH environment variables on Microsoft Windows, Solaris, and Linux. Consult the installation instructions included with your installation of the Java Development Kit (JDK) software packet for current data.

After installing the software, the JDK directory will have the structure shown below.

JDK directory structure

The bin directory contains both the compiler and the launcher.

Update the PATH Environment Variable (Microsoft Windows)

You can run Coffee applications just fine without setting the PATH environment variable. Or, y'all tin optionally set it as a convenience.

Fix the PATH environs variable if you desire to exist able to conveniently run the executables (javac.exe, coffee.exe, javadoc.exe, and so on) from any directory without having to type the total path of the command. If you do not gear up the PATH variable, you demand to specify the full path to the executable every time yous run it, such every bit:

C:\Java\jdk1.7.0\bin\javac MyClass.java          

The PATH environment variable is a series of directories separated past semicolons (;). Microsoft Windows looks for programs in the PATH directories in lodge, from left to right. You should have only one bin directory for the JDK in the path at a time (those following the outset are ignored), so if ane is already present, yous can update that detail entry.

The post-obit is an case of a PATH environs variable:

C:\Java\jdk1.seven.0\bin;C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem          

It is useful to gear up the PATH surroundings variable permanently and then it volition persist after rebooting. To make a permanent change to the PATH variable, use the Organization icon in the Control Panel. The precise procedure varies depending on the version of Windows:

Windows XP

  1. Select Start, select Control Panel. double click Organization, and select the Advanced tab.
  2. Click Environment Variables. In the department Organization Variables, find the PATH environment variable and select it. Click Edit. If the PATH environs variable does not exist, click New.
  3. In the Edit Organisation Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Shut all remaining windows by clicking OK.

Windows Vista:

  1. From the desktop, right click the My Computer icon.
  2. Choose Backdrop from the context carte.
  3. Click the Advanced tab (Advanced system settings link in Vista).
  4. Click Environment Variables. In the department System Variables, find the PATH environment variable and select it. Click Edit. If the PATH environment variable does non exist, click New.
  5. In the Edit Organization Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK.

Windows seven:

  1. From the desktop, right click the Computer icon.
  2. Choose Properties from the context menu.
  3. Click the Avant-garde organisation settings link.
  4. Click Surroundings Variables. In the department System Variables, find the PATH environment variable and select information technology. Click Edit. If the PATH environs variable does non be, click New.
  5. In the Edit System Variable (or New System Variable) window, specify the value of the PATH surroundings variable. Click OK. Close all remaining windows by clicking OK.

Notation: You may see a PATH environs variable like to the post-obit when editing information technology from the Control Panel:

%JAVA_HOME%\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem            

Variables enclosed in percentage signs (%) are existing environment variables. If one of these variables is listed in the Environment Variables window from the Command Panel (such as JAVA_HOME), then you lot tin can edit its value. If information technology does non appear, then it is a special surroundings variable that the operating organization has defined. For example, SystemRoot is the location of the Microsoft Windows organization folder. To obtain the value of a surroundings variable, enter the following at a command prompt. (This example obtains the value of the SystemRoot environment variable):


Update the PATH Variable (Solaris and Linux)

You tin can run the JDK just fine without setting the PATH variable, or you tin can optionally fix information technology every bit a convenience. Even so, you should set the path variable if you desire to be able to run the executables (javac, java, javadoc, and so on) from whatever directory without having to type the total path of the command. If you do not gear up the PATH variable, you need to specify the full path to the executable every fourth dimension yous run it, such as:

% /usr/local/jdk1.seven.0/bin/javac MyClass.java          

To find out if the path is properly set, execute:

This volition print the version of the coffee tool, if it tin can detect information technology. If the version is old or you get the error java: Command not found, so the path is not properly set.

To set the path permanently, set the path in your startup file.

For C trounce (csh), edit the startup file (~/.cshrc):

set path=(/usr/local/jdk1.seven.0/bin $path)          

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

PATH=/usr/local/jdk1.seven.0/bin:$PATH export PATH          

For ksh, the startup file is named by the environment variable, ENV. To set the path:

PATH=/usr/local/jdk1.7.0/bin:$PATH export PATH          

For sh, edit the profile file (~/.profile):

PATH=/usr/local/jdk1.7.0/bin:$PATH consign PATH          

Then load the startup file and verify that the path is set by repeating the java command:

For C beat out (csh):

% source ~/.cshrc % java -version          

For ksh, bash, or sh:

% . /.profile % coffee -version          

Checking the CLASSPATH variable (All platforms)

The CLASSPATH variable is one way to tell applications, including the JDK tools, where to wait for user classes. (Classes that are office of the JRE, JDK platform, and extensions should be defined through other ways, such as the bootstrap class path or the extensions directory.)

The preferred way to specify the class path is past using the -cp control line switch. This allows the CLASSPATH to be set individually for each application without affecting other applications. Setting the CLASSPATH can exist tricky and should be performed with care.

The default value of the form path is ".", meaning that only the current directory is searched. Specifying either the CLASSPATH variable or the -cp command line switch overrides this value.

To check whether CLASSPATH is set on Microsoft Windows NT/2000/XP, execute the post-obit:

On Solaris or Linux, execute the following:

If CLASSPATH is not ready yous will get a CLASSPATH: Undefined variable mistake (Solaris or Linux) or simply %CLASSPATH% (Microsoft Windows NT/2000/XP).

To modify the CLASSPATH, utilise the same procedure you used for the PATH variable.

Class path wildcards permit you lot to include an entire directory of .jar files in the course path without explicitly naming them individually. For more data, including an caption of class path wildcards, and a detailed description on how to clean up the CLASSPATH environment variable, run into the Setting the Class Path technical notation.

How To Set Path In Windows 7 For Java,

Source: https://docs.oracle.com/javase/tutorial/essential/environment/paths.html

Posted by: jonessonstry.blogspot.com

0 Response to "How To Set Path In Windows 7 For Java"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel