File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Development chapter - a few questions.

 
Jan Osykowski
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 316
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic