Just want to make sure I understand this. From experimenting with an example in Chapter 10, if you have a class file:
which is saved in the directory:
MyProject/source/com/wickedlysmart/MyClass.java
and compiled into the directory:
MyProject/classes/com/wickedlysmart/MyClass.class
Invoking
java on MyClass.class won't work unless
A. you use the fully qualified name com/wickedlysmart/MyClass
B. you are in a directory at least one level above the package root (com), in this case, at least MyProject/classes.
C. Also, if you're currently in another subdirectory defined off the project root, in this case, MyProject/source, you can't say
java ../classes/com/wickedlysmart/MyClass without getting a compiler error.
edit: invoking
java -classpath ../classes com/wickedlysmart/MyClass
DOES work... so figured that one out
And, although SB say that adding a dot to the classpath will cause java to search the current directory, I find that if I'm currently in the directory:
MyProject/classes/com/wickedlysmart
invoking either "java -classpath . MyClass" or "java -classpath . com/wickedlysmart/MyClass" causes a NoClassDefFoundError, which seems to contradict what they say, which leads me to inference B above.