当前位置: 代码迷 >> Java相关 >> cmd中编译通过,无法运行,百思不得其解,求高手帮忙啊解决办法
  详细解决方案

cmd中编译通过,无法运行,百思不得其解,求高手帮忙啊解决办法

热度:7611   发布时间:2013-02-25 21:51:53.0
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文件的目录下运行啊!
  相关解决方案