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设定
不明白,请高手讲解

解决方案 »

  1.   

    我建议你把scjp关于开发的知识好好看一看,说实话,这个问题不是自已搞懂,以后换个问法还是难理解。
      

  2.   

    参考大纲:Java语言基础 — Classpath设定
      

  3.   

    参考大纲:Java语言基础 — Classpath设定其他的还真不知道怎么说~
      

  4.   

    B. The JAR file is located at $/JAVA_HOME/jre/lib/ext/myLib.jar.  
    是放到 jre(运行时环境)的扩展jar里边后边两个实在不知道怎么解释。
      

  5.   

    AB相比较,A放classes目录,肯定不对,jar包放lib目录。
    CD相比较,组成类路径的是目录或jar文件,当然不能是某个特定的类,C错。
    EFG中,javac编译参数-cp和-classpath是一样的,但和classpath环境变量一样,不能指向类。-d选项么,你自己知道是错的。
      

  6.   

    买本或下本SCJP考试指南 最后一章开发讲的很详细的
      

  7.   

    B一定是错的。
     $/JAVA_HOME/jre/lib/ext/myLib.jar这种写法代表什么?