| Author |
Error in Sun Certified Programmer for Java 6 Study Guide
|
Jim Carney
Greenhorn
Joined: Oct 13, 2008
Posts: 1
|
|
page 829, question 11. looks to me like the answer is C, not A. and the explanaition as to why it is not C is confusing me... anyone else see this?
|
 |
Vierda Mila
Ranch Hand
Joined: Feb 25, 2008
Posts: 61
|
|
Hi Jim, Kindly to post above question so we can help you in this forum. regards, -Vierda Mila- [ October 13, 2008: Message edited by: Vierda Mila ]
|
SCJP 5
|
 |
Graeme Jenkinson
Greenhorn
Joined: Sep 08, 2008
Posts: 27
|
|
Question (hopefully copied without any mistakes!) Given the following directory structure: And given the contents of GetJar.java and Foo.java: If the current directory is test, which set(s) of commands will successfully compile the two java files and produce the output 8? (Choose all that apply.) A. javac myApp/Foo.java // put into "test" a jar file that contains myApp/Foo.class javac -classpath MyJar.jar GetJar.java java GetJar B. javac myApp/Foo.java // put into "test" a jar file that contains myApp/Foo.class javac MyJar.jar GetJar.java java GetJar C. javac myApp/Foo.java // put into "test" a jar file that contains myApp/Foo.class javac -classpath MyJar.jar GetJar.java java -classpath MyJar.jar GetJar D. javac myApp/Foo.java // put into "test" a jar file that contains myApp/Foo.class javac MyJar.jar GetJar.java java -classpath MyJar.jar GetJar Answer A. I also have some doubts about this. I don't see howthe invocation of java in A can find the class Foo. Whereas, in C both javac and java can locate the class Foo. I also agree that the "explaination" given is rather inadequate. thanks, Graeme [ October 14, 2008: Message edited by: Graeme Jenkinson ]
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
Even C is wrong because it doesn't has the current directory i.e. a "." in the classpath. I have also posted this error, and many others too, but there has been no response from the authors..
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Nidhi Sar
Ranch Hand
Joined: Oct 19, 2009
Posts: 252
|
|
Ankit Garg wrote:Even C is wrong because it doesn't has the current directory i.e. a "." in the classpath. I have also posted this error, and many others too, but there has been no response from the authors..
This is an old forum topic, but I just came across this problem in the book. Ankit, as you pointed out, the only answer that work is the following. It is not one of the choices:
javac -classpath MyJar.jar GetJar.java
java -classpath .:MyJar.jar GetJar.java
You mentioned "many other errors". Is there anyplace you/someone might have compiled these errors? Since the otherwise excellent K&B book is my current main study material, it would be very helpful to have this compilation to refer to.
Thanks,
Nidhi
|
"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
Bert is compiling an errata so look forward to it...
|
 |
Chintan B Shah
Ranch Hand
Joined: Sep 23, 2008
Posts: 83
|
|
I posted this same question about a week back.
This question assumes that you don't have CLASSPATH variable set in your ENVIRONMENT VARIABLES.
Thanks to Daniel for helping me figure this out.
Question No. 11-Chapter 10-Wrong answer
Regards,
Chintan
SCJA 1.0
|
SCJA 1.0
|
 |
Mahtab Alam
Ranch Hand
Joined: Mar 28, 2012
Posts: 57
|
|
why at compiling a . is not included
i thinnk it should be
javac -classpath .:MyJar.jar GetJar.java
java -classpath .:MyJar.jar GetJar
doesn`t javac requires a . (current directory)
|
 |
 |
|
|
subject: Error in Sun Certified Programmer for Java 6 Study Guide
|
|
|