Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

SCJP Java 6 , Study Guide, Chapter 10:Development, Self-test question 11

 
Greenhorn
Posts: 8
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am using the SCJP Java 6 Study Guide. I had a query about the self-test question 11 in chapter 10:Development. For this question, the correct answer is marked as A. I was wondering whether if a default classpath is not provided in the question, should it be assumed that the classpath is . (current directory). Ofcourse, none of the other choices are correct, so leaving A as the only possible answer. I was just wondering if assuming a default classpath of . if not provided is a correct assumption for the exam.

Thank you and Happy New Year 2012!
-A
 
Ranch Hand
Posts: 58
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to set classpath only to access .class files, not the source file. Here current directory is not included in class path and that's okay since MyJar.jar contains the required .class file. Please let me know if I am correct.
 
Arjith Srinivasan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks for your response.
I see what you are saying. However, I was referring to the line that actually runs GetJar

java GetJar

GetJar.class does exist in the same directory at this point, but I was thinking that the classpath needs to be set to . in order to be able to access it. that was the point of my original question.

thanks.


Sebanti Sanyal wrote:You need to set classpath only to access .class files, not the source file. Here current directory is not included in class path and that's okay since MyJar.jar contains the required .class file. Please let me know if I am correct.

 
Sebanti Sanyal
Ranch Hand
Posts: 58
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If no classpath is specified, the current directory (from which java is executed) is searched. If a classpath is specified, the current directory (if required) needs to be added explicitly to the classpath.
Compiling and Launching
 
Arjith Srinivasan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you. I tried unsetting CLASSPATH in my test program and it does locate the .class file as the link you had included mentions... thank you very much.

Sebanti Sanyal wrote:If no classpath is specified, the current directory (from which java is executed) is searched. If a classpath is specified, the current directory (if required) needs to be added explicitly to the classpath.
Compiling and Launching

 
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic