上海手表钢带专卖店:java 运行错误

来源:百度文库 编辑:高考问答 时间:2024/04/28 04:31:06
不知道怎么回事,环境变量我也设置好了, 没有问题,可是每次编译的时候总会出现错误提示:

C:\Documents and Settings\user\桌面>javac HelloWorld.class
javac: invalid flag: HelloWorld.class
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 compiler is doing
-deprecation Output source locations where deprecated APIs are u
sed
-classpath <path> Specify where to find user class files
-cp <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-endorseddirs <dirs> Override location of endorsed standards path
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release

-target <release> Generate class files for specific VM version
-version Version information
-help Print a synopsis of standard options
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system

不知道是那里没有搞好,请高手指点!

javac命令是用来编译java源文件的,即以.java结尾的文件
java命令用来执行编译之后形成的class文件,你把两个命令搞混了

文件保存了吗?

javac HelloWorld.java

这样编译

运行:java HelloWorld

java HelloWorld 就对了。