This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
This is Question number 10 from chapter 10 of Kathy Sierra Book.
If three versions of MyClass.java exist on a file system:
Version 1 is in /foo/bar
Version 2 is in /foo/bar/baz
Version 3 is in /foo/bar/baz/bing
And the system's classpath includes:
And this command line is invoked from /foo
javac -classpath /foo/bar/baz/bing:/foo/bar MyClass.java
Which version will be used by javac?
E. The result is not predictable.
In Book, Answer given is C. But in my opinion answer should be "error :cannot read file MyClass".
Reason being here we are in folder foo , classpath helps to locate the imports used in file and not the file itself.
Unless we do it like this :- javac bar/baz/bing/MyClass.java , Java compiler wont be able to locate this.
I also tried this example on my system, with result as can not find.
Please help me if my understanding is incorrect.