How To Set The Java Classpath In Windows 7
This department explains how to utilise the PATH
and CLASSPATH
surround variables on Microsoft Windows, Solaris, and Linux. Consult the installation instructions included with your installation of the Coffee Development Kit (JDK) software packet for current data.
After installing the software, the JDK directory volition have the structure shown beneath.

The bin
directory contains both the compiler and the launcher.
Update the PATH Environment Variable (Microsoft Windows)
You tin run Java applications just fine without setting the PATH
environment variable. Or, you tin can optionally set information technology as a convenience.
Set the PATH
environs variable if you want to be able to conveniently run the executables (javac.exe
, java.exe
, javadoc.exe
, and and so on) from any directory without having to type the full path of the command. If you practice non set the PATH
variable, you demand to specify the total path to the executable every time you run information technology, such as:
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 guild, from left to right. Y'all should have just one bin
directory for the JDK in the path at a fourth dimension (those post-obit the first are ignored), so if one is already present, you can update that particular entry.
The post-obit is an example of a PATH
environment variable:
C:\Java\jdk1.7.0\bin;C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem
Information technology is useful to set the PATH
environment variable permanently then it will persist after rebooting. To brand a permanent change to the PATH
variable, use the System icon in the Control Console. The precise process varies depending on the version of Windows:
Windows XP
- Select Start, select Control Console. double click Arrangement, and select the Advanced tab.
- Click Environment Variables. In the department Organisation Variables, find the
PATH
environment variable and select it. Click Edit. If thePATH
surroundings variable does non be, clickNew
. - In the Edit System Variable (or New System Variable) window, specify the value of the
PATH
environment variable. Click OK. Shut all remaining windows past clicking OK.
Windows Vista:
- From the desktop, correct click the My Calculator icon.
- Choose Properties from the context menu.
- Click the Advanced tab (Advanced organization settings link in Vista).
- Click Environs Variables. In the section Organisation Variables, find the
PATH
surround variable and select it. Click Edit. If thePATH
environment variable does non exist, clickNew
. - In the Edit Organization Variable (or New System Variable) window, specify the value of the
PATH
surroundings variable. Click OK. Close all remaining windows by clicking OK.
Windows 7:
- From the desktop, right click the Reckoner icon.
- Choose Properties from the context menu.
- Click the Avant-garde organization settings link.
- Click Surroundings Variables. In the section System Variables, find the
PATH
environment variable and select it. Click Edit. If thePATH
surround variable does not exist, clickNew
. - In the Edit System Variable (or New Organisation Variable) window, specify the value of the
PATH
environment variable. Click OK. Close all remaining windows past clicking OK.
Annotation: You may run across 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 percent signs (%
) are existing environment variables. If one of these variables is listed in the Environment Variables window from the Control Console (such as JAVA_HOME
), then y'all can edit its value. If information technology does non appear, and then it is a special environment variable that the operating organization has 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 control prompt. (This example obtains the value of the SystemRoot
environment variable):
Update the PATH Variable (Solaris and Linux)
Y'all can run the JDK just fine without setting the PATH
variable, or you tin optionally ready it every bit a convenience. However, you should set up the path variable if you desire to exist able to run the executables (javac
, java
, javadoc
, and so on) from any directory without having to blazon the full path of the command. If you do not prepare the PATH
variable, you lot need to specify the total path to the executable every fourth dimension you run it, such equally:
% /usr/local/jdk1.vii.0/bin/javac MyClass.coffee
To discover out if the path is properly set, execute:
This volition print the version of the java
tool, if information technology can find it. If the version is old or you get the error java: Command non found, then the path is not properly set.
To gear up the path permanently, gear up the path in your startup file.
For C shell (csh
), edit the startup file (~/.cshrc
):
set path=(/usr/local/jdk1.seven.0/bin $path)
For fustigate
, edit the startup file (~/.bashrc
):
PATH=/usr/local/jdk1.7.0/bin:$PATH export PATH
For ksh
, the startup file is named by the surroundings 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.vii.0/bin:$PATH consign PATH
Then load the startup file and verify that the path is set by repeating the java
command:
For C vanquish (csh
):
% source ~/.cshrc % coffee -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 look for user classes. (Classes that are function of the JRE, JDK platform, and extensions should exist defined through other means, such every bit the bootstrap form path or the extensions directory.)
The preferred way to specify the class path is by using the -cp
command line switch. This allows the CLASSPATH
to be prepare individually for each application without affecting other applications. Setting the CLASSPATH
tin can be tricky and should exist performed with care.
The default value of the class path is ".", pregnant that only the current directory is searched. Specifying either the CLASSPATH variable or the -cp
control line switch overrides this value.
To bank check whether CLASSPATH
is set on Microsoft Windows NT/2000/XP, execute the following:
On Solaris or Linux, execute the post-obit:
If CLASSPATH
is not set you volition get a CLASSPATH: Undefined variable mistake (Solaris or Linux) or simply %CLASSPATH% (Microsoft Windows NT/2000/XP).
To modify the CLASSPATH
, employ the same procedure yous used for the PATH
variable.
Class path wildcards let you to include an entire directory of .jar
files in the course path without explicitly naming them individually. For more than information, including an explanation of grade path wildcards, and a detailed clarification on how to clean up the CLASSPATH
environment variable, meet the Setting the Class Path technical notation.
Source: https://docs.oracle.com/javase/tutorial/essential/environment/paths.html
Posted by: burnsallasted88.blogspot.com
0 Response to "How To Set The Java Classpath In Windows 7"
Post a Comment