我汗。。。 您够纠结的。。。前面先说能够运行,后面又说不能运行。。。
看你的异常 应该是TEST类文件里不包含main方法的缘故(估计是你写错了)main方法写法是
public static void main(String[] args){
...
}
。。还有javac编译时你为什么要写包.java。。。你在哪里看到可疑这样编译的了。
最好一个问题。。。javac help是错误的指令。。。应该是javac -help ,同理,还有javac version要写成javac -version
配置好了环境变量??? 貌似没配置好吧?配置好了就不会出现“.java时出现无效的标志”!
重点是 classpath 的路径 .;D:\Program Files\Java\jre1.6.0\lib;
在dos目录 输入 java 出现很多命令 才是环境变量配置好了!
C:\Documents and Settings\Administrator>java
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp
-classpath
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -jre-no-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
或者dos下输入 java -version 出现
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)
才是环境变量配置好了!
检查一下你的CLASSPATH配置好了吗