高手进:“Java 环境已经配好~~javac也能通过,不过一执行(java)就错

来源:百度知道 编辑:UC知道 时间:2024/06/01 03:10:29
开始 java _version
显示:java version "1.4.2_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_
Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
点击:javac hello
显示:javac: invalid flag: hello
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compile
-deprecation Output source locations where deprecat
ed
-classpath <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source fil
-bootclasspath <path> Override location of bootstrap class f
-extdirs <dirs>

CLASS %JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
不知道是不是你写错了,应该是classpath,另外在前面把.;加上。
CLASSPATH .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
如果还是有问题,检查一下你的hello.java的内容,主类名是不是叫hello,另外是不是用public修饰
如果还有问题,建议把hello.java代码也贴上来

编译的命令是 javac Hello.java
执行的命令是 java Hello