Hi,
I consider the example from
SCJP Sun Certified Programmer for
Java 6 Study Guide by Katherine Sierra and Bert Bates (K&B) Page number 817, Chapter 10 and Question no 11. The correct answer according to the book is option A.
The second command is java GetJar, my quesion is how does it find the MyJar.jar without providing classpath or does it use the current directory as used for GetJar.class but it does not work.
11. Given the following directory structure:
test-|
|- GetJar.java
|
|- myApp-|
|-Foo.java
And given the contents of GetJar.java and Foo.java:
3. public class GetJar {
4. public static void main(
String[] args) {
5. System.out.println(myApp.Foo.d);
6. }
7. }
3. package myApp;
4. public class Foo { public static int d = 8; }
If the current directory is "test", and myApp/Foo.class is placed in a JAR file called MyJar.jar
located in
test, which set(s) of commands will compile GetJar.java and produce the output 8?
(Choose all that apply.)
Answer:
A.
javac -classpath MyJar.jar GetJar.java
java GetJar
Thank you.