关于JAVAC问题
情况介绍:1、安装版本java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Client VM (build 24.0-b56, mixed mode, sharing
2、查看 JVAV,JAVAC命令,可以出现帮助信息
EXP:C:\Documents and Settings\cxz>java
用法: java [-options] class [args...]
(执行类)
或 java [-options] -jar jarfile [args...]
(执行 jar 文件)
…………………………
3、PATH路径:C:\Documents and Settings\cxz>set path
Path=D:\java\jdk1.7.0_40/bin;D:\java\jdk1.7.0_40\jre\bin;d:\oracle\product\10.1.
0\Db_1\bin;d:\oracle\product\10.1.0\Db_1\jre\1.4.2\bin\client;d:\oracle\product\
10.1.0\Db_1\jre\1.4.2\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbe
m;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
4、CLASSPATH路径:C:\Documents and Settings\cxz>set classpath
classpath=.;d:\java\javawork;D:\java\jdk1.7.0_40\bin;D:\java\jdk1.7.0_40\lib;D:\
java\jdk1.7.0_40\jre
5、编写程序文件放在d:\java\javawork目录下,JDK,在d:\java下,JRE 在d:\java目录下。
问题;只能在d:\java\javawork下使用javac lesson2.java ;在任何目录下均可运行java lesson2
D:\java\javawork>dir
…………………………………………
2013-10-03 12:14 1,074 lesson2.class
2013-10-03 11:29 1,048 lesson2.java //部分现实内容
………………………………………………
D:\java\javawork>javac lesson2.java
D:\java\javawork>java lesson2
1
3
5
7
9
在其他目录试验
C:\Documents and Settings\cxz>javac lesson2.java
javac: 找不到文件: lesson2.java
用法: javac
-help 用于列出可能的选项
C:\Documents and Settings\cxz>java lesson2
1
3
5
7
9
这种情况是原因,,想达到,在任何目录可以编译 D:\java\javawork目录下编写的JAVA文件。
附录:编译详细过程(本机安装了ORACLE,自带1.4.2版本JDK)
D:\java\javawork>javac lesson2.java -verbose
[解析开始时间 RegularFileObject[lesson2.java]]
[解析已完成, 用时 47 毫秒]
[源文件的搜索路径: .,D:\java\jdk1.7.0_40\bin,D:\java\jdk1.7.0_40\lib,D:\java\jdk
1.7.0_40\jre]
[类文件的搜索路径: D:\java\jdk1.7.0_40\jre\lib\resources.jar,D:\java\jdk1.7.0_40
\jre\lib\rt.jar,D:\java\jdk1.7.0_40\jre\lib\sunrsasign.jar,D:\java\jdk1.7.0_40\j
re\lib\jsse.jar,D:\java\jdk1.7.0_40\jre\lib\jce.jar,D:\java\jdk1.7.0_40\jre\lib\
charsets.jar,D:\java\jdk1.7.0_40\jre\lib\jfr.jar,D:\java\jdk1.7.0_40\jre\classes
,D:\java\jdk1.7.0_40\jre\lib\ext\access-bridge.jar,D:\java\jdk1.7.0_40\jre\lib\e
xt\dnsns.jar,D:\java\jdk1.7.0_40\jre\lib\ext\jaccess.jar,D:\java\jdk1.7.0_40\jre
\lib\ext\localedata.jar,D:\java\jdk1.7.0_40\jre\lib\ext\sunec.jar,D:\java\jdk1.7
.0_40\jre\lib\ext\sunjce_provider.jar,D:\java\jdk1.7.0_40\jre\lib\ext\sunmscapi.
jar,D:\java\jdk1.7.0_40\jre\lib\ext\sunpkcs11.jar,D:\java\jdk1.7.0_40\jre\lib\ex
t\zipfs.jar,.,D:\java\jdk1.7.0_40\bin,D:\java\jdk1.7.0_40\lib,D:\java\jdk1.7.0_4
0\jre]
[正在加载ZipFileIndexFileObject[D:\java\jdk1.7.0_40\lib\ct.sym(META-INF/sym/rt.j
ar/java/lang/Object.class)]]
[正在加载ZipFileIndexFileObject[D:\java\jdk1.7.0_40\lib\ct.sym(META-INF/sym/rt.j
ar/java/lang/String.class)]]
[正在检查lesson2]
[正在加载ZipFileIndexFileObject[D:\java\jdk1.7.0_40\lib\ct.sym(META-INF/sym/rt.j
ar/java/lang/AutoCloseable.class)]]
[正在加载ZipFileIndexFileObject[D:\java\jdk1.7.0_40\lib\ct.sym(META-INF/sym/rt.j
ar/java/lang/System.class)]]
[正在加载ZipFileIndexFileObject[D:\java\jdk1.7.0_40\lib\ct.sym(META-INF/sym/rt.j
ar/java/io/PrintStream.class)]]
[正在加载ZipFileIndexFileObject[D:\java\jdk1.7.0_40\lib\ct.sym(META-INF/sym/rt.j
ar/java/io/FilterOutputStream.class)]]
[正在加载ZipFileIndexFileObject[D:\java\jdk1.7.0_40\lib\ct.sym(META-INF/sym/rt.j
ar/java/io/OutputStream.class)]]
[正在加载ZipFileIndexFileObject[D:\java\jdk1.7.0_40\lib\ct.sym(META-INF/sym/rt.j
ar/java/io/InputStream.class)]]
[正在加载ZipFileIndexFileObject[D:\java\jdk1.7.0_40\lib\ct.sym(META-INF/sym/rt.j
ar/java/io/Closeable.class)]]
[正在加载ZipFileIndexFileObject[D:\java\jdk1.7.0_40\lib\ct.sym(META-INF/sym/rt.j
ar/java/lang/Exception.class)]]
[正在加载ZipFileIndexFileObject[D:\java\jdk1.7.0_40\lib\ct.sym(META-INF/sym/rt.j
ar/java/lang/Throwable.class)]]
[正在加载ZipFileIndexFileObject[D:\java\jdk1.7.0_40\lib\ct.sym(META-INF/sym/rt.j
ar/java/lang/Error.class)]]
[正在加载ZipFileIndexFileObject[D:\java\jdk1.7.0_40\lib\ct.sym(META-INF/sym/rt.j
ar/java/io/IOException.class)]]
[正在加载ZipFileIndexFileObject[D:\java\jdk1.7.0_40\lib\ct.sym(META-INF/sym/rt.j
ar/java/lang/RuntimeException.class)]]
[已写入RegularFileObject[lesson2.class]]
[共 656 毫秒]
----------------解决方案--------------------------------------------------------