A developer is creating a class Book, that needs to access class Paper. The Paper class is deployed in a JAR named myLib.jar.
Which three, taken independently, will allow the developer to use the Paper class
while compiling the Book class? (choose three)
A. The JAR file is located at $JAVA_HOME/jre/classes/myLib.jar
B. The JAR file is located at $/JAVA_HOME/jre/lib/ext/myLib.jar.
C. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set
that includes /foo/myLib.jar/Paper,Class.
D. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set
that includes /foo/myLib.jar.
E. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac
-cp /foo/myLib.jar/Paper Book java.
F. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -d
/foo/myLib.jar Book java.
G. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -classpath /foo/myLib.jar Book.java
Answer: ( B, D, G )
Javac -d 指定编译后的文件存放的位置
Javac –cp 指定编译时需要用到的类文件位置
参考大纲:Java语言基础 — Classpath设定
不明白,请高手讲解
Which three, taken independently, will allow the developer to use the Paper class
while compiling the Book class? (choose three)
A. The JAR file is located at $JAVA_HOME/jre/classes/myLib.jar
B. The JAR file is located at $/JAVA_HOME/jre/lib/ext/myLib.jar.
C. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set
that includes /foo/myLib.jar/Paper,Class.
D. The JAR file is located at /foo/myLib.jar and a classpath environment variable is set
that includes /foo/myLib.jar.
E. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac
-cp /foo/myLib.jar/Paper Book java.
F. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -d
/foo/myLib.jar Book java.
G. The JAR file is located at /foo/myLib.jar and the Book class is compiled using javac -classpath /foo/myLib.jar Book.java
Answer: ( B, D, G )
Javac -d 指定编译后的文件存放的位置
Javac –cp 指定编译时需要用到的类文件位置
参考大纲:Java语言基础 — Classpath设定
不明白,请高手讲解
是放到 jre(运行时环境)的扩展jar里边后边两个实在不知道怎么解释。
CD相比较,组成类路径的是目录或jar文件,当然不能是某个特定的类,C错。
EFG中,javac编译参数-cp和-classpath是一样的,但和classpath环境变量一样,不能指向类。-d选项么,你自己知道是错的。
$/JAVA_HOME/jre/lib/ext/myLib.jar这种写法代表什么?