只问耕耘
分类: Java
2010-01-08 11:54:08
在classpath中不要忘记 ".",如:
D:\workspace\test>java -cp .;d:\hello.jar c1.Test
The CLASSPATH
variable is one way to tell applications, including the JDK tools, where to look for user classes. (Classes that are part of the JRE, JDK platform, and extensions should be defined through other means, such as the bootstrap class 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 set individually for each application without affecting other applications. Setting the CLASSPATH
can be tricky and should be performed with care.
The default value of the class 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 following:
On Solaris or Linux, execute the following:C:> echo %CLASSPATH%
If% echo $CLASSPATH
CLASSPATH
is not set you will get a CLASSPATH: Undefined variable error (Solaris or Linux) or simply %CLASSPATH% (Microsoft Windows NT/2000/XP).
To modify the CLASSPATH
, use the same procedure you used for the PATH
variable.
Class path wildcards allow you to include an entire directory of .jar
files in the class path without explicitly naming them individually. For more information, including an explanation of class path wildcards, and a detailed description on how to clean up the CLASSPATH
environment variable, see the technical note.