• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

K&B SCJP 5 book: class path and jar files question

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I don't understand this part of explanation in K&B SCJP 5 book, Page798:


B,D, and F are incorrect because java needs a classpath that specifies two directories, one for the class file(the .directory), and one for the JAR file( the com directory).



Or simply, I don't understand in answer H:
why "-classpath com/KitJar.jar:." is wrong.

Any helpers? thank you.
[ June 10, 2006: Message edited by: warren li ]
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

why "-classpath com/KitJar.jar:." is wrong.



Why are you saying it's wrong above.

"-classpath com/KitJar.jar:." is correct.

Anyway, I think I know what you mean.

A full expalanation is here.

Basically, go to Control Panel -> System and remove ".". Try to compile and run. You will notice an exception occurs. So you need to specify "." in -cp if it's not in System.

The Bonus Exam may have a similar question. Read this for more info.
[ June 11, 2006: Message edited by: Firas Zureikat ]
 
warren li
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you didn't explain the quoted text.
 
Firas Zuriekat
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does K&B say that "-classpath com/KitJar.jar:." is wrong?. It doesn't say it's wrong. It's actually the correct answer. You need the "." if your CLASSPATH doesn't already have "." there.

May be someone else could help. I might have misunderstood the question.
 
warren li
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry. please read the book on that page first. thanks.
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Firas you are correct.
Answer H is correct, you always need two classpaths when the two class files are existing in different location.
 
warren li
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Firas Zureikat:


Why are you saying it's wrong above.

"-classpath com/KitJar.jar:." is correct.

Anyway, I think I know what you mean.

A full expalanation is here.

Basically, go to Control Panel -> System and remove ".". Try to compile and run. You will notice an exception occurs. So you need to specify "." in -cp if it's not in System.

The Bonus Exam may have a similar question. Read this for more info.

[ June 11, 2006: Message edited by: Firas Zureikat ]





Sorry I read the answer wrongly, I thought F was correct.
but after reading the thread you referred, I am much clearer now. Thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic