怎样设置classpath

来源:百度知道 编辑:UC知道 时间:2024/06/21 03:47:18
我的环境下javac运行的了帮助.编译也能通过就是运行时出现
Exception in thread "main"java.long.NoClassDefFoundError :
我的classpath是这样写的.\;%JAVA_HOME%\lib\tools.jar
jdk是默认安装的,class文件在D盘

main方法抛出异常~~

不是设置classpath,是设置Path

找到你的JDK装安目录~~

例如:
C:\Program Files\Java\jdk1.5.0_07\bin;

将这个路径放到Path最前面,
注意,要在路径后加一个分号[ ; ]

再试一下~~

在DOS里输入java,如果会出现以下:

Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)

where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.

-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class