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

重新提问: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提示错误信息:
C:\Documents and Settings\Administrator>java c:\hello
Exception in thread "main" java.lang.NoClassDefFoundError: c:\hello
Caused by: java.lang.ClassNotFoundException: c:\hello
  at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: c:\hello. Program will exit.

------解决方案--------------------
java c:\hello


这叫什么事儿

java.exe后面只需跟类名就行了

它会自动到classpath中去找到对应的.class文件的,这个c:\hello算啥回事儿?