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

classpath for jar file K&B

 
Ferwed Kondos
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K&B chapter 10 - Q 12

And the following sub-directory structure:

test
|--UseKit.class
|
com
|--KitJar.jar

If the current directory is test, and the file pkg/Kit.class is in KitJar.jar, which
command line will produce the output bc ? (Choose all that apply.)
A. java UseKit b c
B. java UseKit a b c
C. java -classpath com UseKit b c
D. java -classpath com:. UseKit b c
E. java -classpath com/KitJar.jar UseKit b c
F. java -classpath com/KitJar.jar UseKit a b c
G. java -classpath com/KitJar.jar:. UseKit b c
H. java -classpath com/KitJar.jar:. UseKit a b c

Answer is H
I dont understand why F is false, why specifying the dot in the classpath is required?
 
Henry Wong
author
Marshal
Pie
Posts: 20823
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the relevant quote from the Sun Java web site:

The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.


Henry
 
Ferwed Kondos
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry
So the dot in the classpath is to find the class in the current directory I want to run which is UseKit?
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic