这个简单运行的JAVA类出了什么问题?

时间:2013-11-17 11:04:45

标签: java

我不知道为什么我不能运行编译的java类。甚至很简单。请参阅下文。

C:\javatest>echo %CLASSPATH%
C:\Program Files\Java\jdk1.7.0_45\bin; C:\Program Files\Java\jdk1.7.0_45\jre\bin


C:\javatest>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.7.0_45

C:\javatest>cat hello.java
class hello{
public static void main(String[] agrs){
    System.out.println("Hello world");
}
}
C:\javatest>javac hello.java

C:\javatest>java hello.class
Error: Could not find or load main class hello.class

C:\javatest>java -cp . hello.class
Error: Could not find or load main class hello.class

C:\javatest>

Windows路径中的JAVA C:\ Program Files \ Java \ jdk1.7.0_45 \ bin

请帮忙。

EDITED

C:\javatest>java hello
Error: Could not find or load main class hello

C:\javatest>java.exe hello
Error: Could not find or load main class hello

1 个答案:

答案 0 :(得分:4)

使用如下命令:

C:\javatest>java hello  //Don't enter .class extension