刚在java.sun.com上下载的:jdk-6u16-windows-i586.exe
安装在D:\Sun下。
环境变量设置:
JAVA_HOME=D:\Sun\Java\jdk1.6.0_16
classpath=%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
path=%JAVA_HOME%\bin
HelloWorld.java文件代码:
public class HelloWorld
{
public static void main(String[] args)
{
System.out.print("Hello..."); }
}
javac HelloWorld.java --------编译正常
java HelloWorld -------报错,错误信息:
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
Caused by: java.lang.ClassNotFoundException: HelloWorld
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: HelloWorld. Program will exit.
------解决方案--------------------
代码迷推荐解决方案:java环境变量设置,http://www.daimami.com/search?q=172921
------解决方案--------------------
classpath=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
------解决方案--------------------
就是在前面加个点加个分号
------解决方案--------------------
你先编译了吗?