Hi all,
There is one question in self-test of K&B book which I would like to discuss with you.
The question is :
Given the following directory structure:
test - |
|- GetJar.java
|
|- myApp - |
|-Foo.java
And given the contents of GetJar.java and Foo.java
If the current directory is "test", and myApp/Foo.class is placed in a JAR file called MyJar.jar located in the test, which set(s) of command will compile GetJar.java and produce the output 8?
And correct answer given in the book is :
javac -classpath MyJar.jar GetJar.java
java GetJar
Now , as per my understanding java compiler won't search for files in current directory if it is not specified in classpath with (.). Then if we are not specifying (.) in classpath, how compiler is able to find GetJar.java?
This may sound like a silly question bu t as I am using
IDE a lot for development and I have never used command prompt for compiling and executing java files, I am confused.
Could you please help me out?