Yes It made me confused too
JVM needs to find the same classes as the javac( java compiler ) needs to find!!!
But now its more clear to me and its true!!!
you just mugup this statement its really true and
as of your qustion
see here Getjar class is using the static variable of the Foo class
and Foo class is in myApp package........as you must have read in K.Sierra's book
that when we create a jar file the directory structure is preserved in that file!!!
so here as the javac ( java compiler ) needs to find Foo class either class paths will work
the one given in option a of the book i.e
a) javac -cp MyJar.jar GetJar.java
as well as
javac -cp . GetJar.java or javac Getjar.java
( because as you can see in question the System.out.println statement is using fully qualified class name that is myApp.Foo so the javac will search in current directory that is test and will find myApp/Foo.java also javac command searches for the class in current directory by default
as for the java command
if you say
java -cp MyJar.jar GetJar
it wont find GetJar.class as it is not in the MyJar.jar file........phew!!!
and java Getjar will work because it will find both Getjar.class as well as myApp.Foo class
( PS: I am little confused about last statement that java command doesnt search for classes in current directory by default then why it gets executed??? )
maybe im forgetting something
Cheers for whatever youve understood!!!