| Author |
Development chapter - a few questions.
|
Jan Osykowski
Ranch Hand
Joined: Jul 15, 2010
Posts: 41
|
|
Hey guys,
I got some question about the Development Self Test.
First of all the question number 12.
And as the right answers the F and G are listed:
F. java -classpath .:test/MyJar.jar GoDeep
G. java -classpath test/MyJar.jar:. GoDeep
but I also think that the answer C is good:
C. F. java -classpath test/MyJar.jar GoDeep
(which is the same as F and G just without the current directory to look for)
but if we are in the directory "x" then there is nothing to look for there. I mean, the GoDeep.class while executed will look for Foo.class which is accesible in test/MyJar.jar so the classpath equal to "test/MyJar.jar" should be enought, no? What do you guys think?
And another question number 11 which is cited here: http://www.coderanch.com/t/474863/java-programmer-SCJP/certification/Mistake-GuideBook-SCJP-Java-Chapter
I am wondering how would the correct answer look like. Why it is not C? I mean the JAR file is in the current directory so just pointing it shouldn't be bad. Or another solution I can see is something like this:
What would be the correct solution for this task? I mean besides the 4 proposed in the answer sheet.
Cheers,
Jan.
|
 |
Sahil Kapoor
Ranch Hand
Joined: Sep 12, 2009
Posts: 316
|
|
javac sees the current directory by default for .java files
java looks for .class files only in the default classpath ot the classpath you mentioned......
If you do not mention . (current Directory) then it woild not be able to find GODeep.class. Hence it is mandatory .
|
SCJP 6.0 96%
(Connecting the Dots ....)
|
 |
Shanky Sohar
Ranch Hand
Joined: Mar 17, 2010
Posts: 1046
|
|
Sahil Kapoor wrote:javac sees the current directory by default for .java files
java looks for .class files only in the default classpath ot the classpath you mentioned......
in case of relative class paths JVM looks for current directory................
but for absolute classpath........current directory doesnot matter.........because we have to give the complete path of file
|
SCJP6.0,My blog Ranchers from Delhi
|
 |
 |
|
|
subject: Development chapter - a few questions.
|
|
|