I have a, probably novice, question about a piece of text in Chapter 10. I quote:
...let's look at another example:
import com.wickedlysmart.Utils;
class TestClass { void doStuff() { Utils myUtils = new Utils(); // simple name myUtils.doX("arg1", "arg2"); com.wickedlysmart.Date d = new com.wickedlysmart.Date(); // full name d.getMonth("Oct"); } }
In this case we're using two classes from the package com.wickedlysmart. For the sake of discussion we imported the fully qualified name for the Utils class, and we didn't for the Date class. The only difference is that because we listed Utils in an import statement, we didn't have to type its fully qualified name inside the class. In both cases the package is com.wickedlysmart. When it's time to compile or run TestClass, the classpath will have to include a directory with the following attributes:
A subdirectory named com (we'll call this the "package root" directory) A subdirectory in com named wickedlysmart Two files in wickedlysmart named Utils.class and Date.class
Now my question is, does the last written piece say:
"classpath will have to include a directory with any of the following attributes" ?
or
"classpath will have to include a directory with all the following attributes" ?
When I read it, it seems to me, if I am using a class MyClass in com/foo/bar, the classpath has to include com, and com/foo, and com/foo/bar, and com/foo/bar/MyClass.class. Then cannot be true now can it?
SCJP5
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
posted
0
I read it as meaning that the CLASSPATH contains the name of a directory which contains the directory com.
So if we had a directory /dev/src (the package root) and it contains the com directory, then the CLASSPATH would be of the form <other-dirs-or-jars>:/dev/src:<other-dirs-or-jars>
Taking a look at where the class files would be: we have two files Utils.class and Date.class in a directory /dev/src/com/wickedlysmart [ May 18, 2007: Message edited by: Barry Gaunt ]