aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Chapter 10 Developement Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Chapter 10 Developement" Watch "Chapter 10 Developement" New topic
Author

Chapter 10 Developement

Marc Wentink
Ranch Hand

Joined: May 18, 2007
Posts: 142
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
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 ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Chapter 10 Developement
 
Similar Threads
Chap.10 Development , Q5 pg813 : not understood answer and cannot run code
Clarification on classpaths
Problm with -d
Unable to set CLASSPATH in Linux-based OS
please help me for this package question