Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Development

 
swaraj gupta
Ranch Hand
Posts: 182
C++ Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the following subdirectory structure:

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

If the current directory is test, and the file pkg/Kit.class is in KitJar.jar, which command line will produce the output bc?

One of the answer is: "> java -cp com:. UseKit a b c"

I am not getting this answer. Please let me know the reason.
 
Henry Wong
author
Marshal
Pie
Posts: 20836
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
swaraj gupta wrote:
If the current directory is test, and the file pkg/Kit.class is in KitJar.jar, which command line will produce the output bc?

One of the answer is: "> java -cp com:. UseKit a b c"

I am not getting this answer. Please let me know the reason.


Did the question just ask whether it will work? Or will it work by using in the class in the jar file?

With that run, it will work -- but it will use the Kit.class file directory (in the test.com.pkg directory). And not the kit.class file in the jar file.

Henry
 
swaraj gupta
Ranch Hand
Posts: 182
C++ Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did the question just ask whether it will work? Or will it work by using in the class in the jar file?

I have put the question exactly in the same way it is asked. The question is having other options as well but those are clear to me.

With that run, it will work -- but it will use the Kit.class file directory (in the test.com.pkg directory). And not the kit.class file in the jar file.
How is it possible if interpretor is instructed to search for the supporting Kit.class in:
1> com package
2> current directory (test)

and both do not have the Kit.class file.
 
Henry Wong
author
Marshal
Pie
Posts: 20836
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
swaraj gupta wrote:
With that run, it will work -- but it will use the Kit.class file directory (in the test.com.pkg directory). And not the kit.class file in the jar file.
How is it possible if interpretor is instructed to search for the supporting Kit.class in:
1> com package
2> current directory (test)

and both do not have the Kit.class file.


The classpath specifies the *root* directories to search in, and not the exact directories to search in... and since the Kit class is in the pkg package, it will searching in the pkg directory off of those root dirs that you listed, for that class.

Henry
 
swaraj gupta
Ranch Hand
Posts: 182
C++ Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry sir, I didn't get your point..
The classpath specifies the *root* directories to search in, and not the exact directories to search in.


According to my weak knowledge: "classpath option is used to specify the paths where java or javac look in to search for the supporting files for the compilation or execution operation to be successful."
 
Henry Wong
author
Marshal
Pie
Posts: 20836
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
swaraj gupta wrote:
The classpath specifies the *root* directories to search in, and not the exact directories to search in.


According to my weak knowledge: "classpath option is used to specify the paths where java or javac look in to search for the supporting files for the compilation or execution operation to be successful."


Maybe it would be good idea to revisit how classpaths work...

http://download.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html

Because it is not as simple as a list of directories to search for files -- it also depends on what package the classes are in.

Henry
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic