日期:2014-05-20  浏览次数:20938 次

cmd中编译通过,无法运行,百思不得其解,求高手帮忙啊
JAVA_HOME: C:\Program Files\Java\jdk1.6.0_24
classpath: .;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib
Path: %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin
程序代码为
public class hello {
  public static void main (String args[])
  {
System.out.println("hello");
  }
}

用java命令运行时cmd提示错误信息:
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)
Could not find the main class: HelloWorld. Program will exit.

------解决方案--------------------
要去你那个class文件的目录下运行啊!