我不知道为什么我不能运行编译的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
答案 0 :(得分:4)
使用如下命令:
C:\javatest>java hello //Don't enter .class extension