a***n 发帖数: 1616 | 1 只写一个目录,会不会包含该目录下的所有.jar里的class?
如果是.zip呢,是不是要写目录+包文件的全名? |
z****g 发帖数: 2497 | 2 1. no. no jar file will be included.
2. I don't think java classpath would recognize zip file at all.
【在 a***n 的大作中提到】 : 只写一个目录,会不会包含该目录下的所有.jar里的class? : 如果是.zip呢,是不是要写目录+包文件的全名?
|
m**c 发帖数: 90 | 3
Wrong. Java archive files can be in either JAR or ZIP format. For example,
Oracle JDBC (thin) driver is packaged as "classes12.zip". You can tread just
ZIP file as JAR file:
(Windows) set CLASSPATH=...\classes12.zip;...
(UNIX) export CLASSPATH=.../classes12.zip:...
【在 z****g 的大作中提到】 : 1. no. no jar file will be included. : 2. I don't think java classpath would recognize zip file at all.
|
a***n 发帖数: 1616 | 4 我的关键问题是,如果是.jar,可不可以只写目录名,它会自动找目录里所有jar
里面包含的class?
为什么我装的J2SDK,默认的classpath是 jdk/lib/tools.jar:jdk/jre/lib
其中jdk/jre/lib里有java所需的所有class包:rt.jar。
它为什么不用jdk/jre/lib/rt.jar,或者干脆用 jdk/share/src.zip呢(src.zip也包含
java所需的所有class)。
是不是jdk1.4放宽要求,对jar内建支持,不用些全jar的文件名,只要目录它就可以搜?
【在 m**c 的大作中提到】 : : Wrong. Java archive files can be in either JAR or ZIP format. For example, : Oracle JDBC (thin) driver is packaged as "classes12.zip". You can tread just : ZIP file as JAR file: : (Windows) set CLASSPATH=...\classes12.zip;... : (UNIX) export CLASSPATH=.../classes12.zip:...
|
a***n 发帖数: 1616 | 5 太武断了,答案作废
【在 z****g 的大作中提到】 : 1. no. no jar file will be included. : 2. I don't think java classpath would recognize zip file at all.
|
e***g 发帖数: 158 | 6
never heard of. jre/lib as classpath is for resources like font.properties,
images/...gif. rt.jar is in bootclasspath and not affected by classpath
【在 a***n 的大作中提到】 : 我的关键问题是,如果是.jar,可不可以只写目录名,它会自动找目录里所有jar : 里面包含的class? : 为什么我装的J2SDK,默认的classpath是 jdk/lib/tools.jar:jdk/jre/lib : 其中jdk/jre/lib里有java所需的所有class包:rt.jar。 : 它为什么不用jdk/jre/lib/rt.jar,或者干脆用 jdk/share/src.zip呢(src.zip也包含 : java所需的所有class)。 : 是不是jdk1.4放宽要求,对jar内建支持,不用些全jar的文件名,只要目录它就可以搜?
|
m**c 发帖数: 90 | 7
I don't not quite understand with the translated terminology (in Chinese) as
you mentioned above :-) Let's use an example: you have "my.jar", if you
include "my.jar" in CLASSPATH, every classes (compiled bytecode) in "my.jar"
will be loaded to JVM:
set CLASSPATH=\my.jar (Windows)
export CLASSPATH=/my.jar (Unix)
Since "src.zip" only contains the source code (*.java) not compiled bytecode
(*.classes). Therefore, you cannot add "src.zip" to CLASSPATH (in fact, you
could do it, but J
【在 a***n 的大作中提到】 : 我的关键问题是,如果是.jar,可不可以只写目录名,它会自动找目录里所有jar : 里面包含的class? : 为什么我装的J2SDK,默认的classpath是 jdk/lib/tools.jar:jdk/jre/lib : 其中jdk/jre/lib里有java所需的所有class包:rt.jar。 : 它为什么不用jdk/jre/lib/rt.jar,或者干脆用 jdk/share/src.zip呢(src.zip也包含 : java所需的所有class)。 : 是不是jdk1.4放宽要求,对jar内建支持,不用些全jar的文件名,只要目录它就可以搜?
|
a***n 发帖数: 1616 | 8 多谢,完全明白了.
那么安装的j2sdk,它默认设classpath=.:/lib/tools.jar:/jre/lib
里的"/jre/lib"根本没有意义嘛,除非你想把一个个的class文件放那里,谁干?
目录它=目录,它:)
【在 m**c 的大作中提到】 : : I don't not quite understand with the translated terminology (in Chinese) as : you mentioned above :-) Let's use an example: you have "my.jar", if you : include "my.jar" in CLASSPATH, every classes (compiled bytecode) in "my.jar" : will be loaded to JVM: : set CLASSPATH=\my.jar (Windows) : export CLASSPATH=/my.jar (Unix) : Since "src.zip" only contains the source code (*.java) not compiled bytecode : (*.classes). Therefore, you cannot add "src.zip" to CLASSPATH (in fact, you : could do it, but J
|
z****g 发帖数: 2497 | 9 我知道的是.jar,如果只指明目录的话,是不会被搜索到的。
这个时候,用ant就显出优势来了。
ant可以指出目录就可以了。 而且可以搜索子目录。
【在 a***n 的大作中提到】 : 我的关键问题是,如果是.jar,可不可以只写目录名,它会自动找目录里所有jar : 里面包含的class? : 为什么我装的J2SDK,默认的classpath是 jdk/lib/tools.jar:jdk/jre/lib : 其中jdk/jre/lib里有java所需的所有class包:rt.jar。 : 它为什么不用jdk/jre/lib/rt.jar,或者干脆用 jdk/share/src.zip呢(src.zip也包含 : java所需的所有class)。 : 是不是jdk1.4放宽要求,对jar内建支持,不用些全jar的文件名,只要目录它就可以搜?
|
m**c 发帖数: 90 | 10
Remember, sometimes, not only class file needs to be in the CLASSPATH, but
also other type of files. For example, properties file. If you take a look
at /jre/lib, you will see some files with extension ".properties". Those
files are used as configuration files which must be in the CLASSPATH,
otherwise, some classes will complain about it. When a directory is included
in the CLASSPATH, you can load any file using
"obj.getClass().getResourcesAsStream(...)". This can be very useful: let
【在 a***n 的大作中提到】 : 多谢,完全明白了. : 那么安装的j2sdk,它默认设classpath=.:/lib/tools.jar:/jre/lib : 里的"/jre/lib"根本没有意义嘛,除非你想把一个个的class文件放那里,谁干? : : 目录它=目录,它:)
|