Oliver Wong wrote:
>> Did you try compiling the files while ensuring that the current
>> directory be ~ben/docs/comp/lang/java/ ? Did you ensure that "." (the
>> current directory) is part of the CLASSPATH environment variable?
> Yes to the former, no to the latter. Adding "." to the CLASSPATH
> environment variable fixes my problem on the Linux box.
>
> My main system has no CLASSPATH environment variable. Since it has no
> problem, I guess its Java has a built-in class path with "."
Java has no "built-in class path", but your Windows box might.
Generally it is better to script (preferably with Ant) the classpath, invoking
the -cp (-classpath) option to the 'java' command, rather than to use the
CLASSPATH envar. CLASSPATH is global and inflexible, whereas "-cp" is
particular and adaptable.
Also, it is a Bad Thing to use the "default package" for classes.
Better is to use a (possibly fictional) domain, for example "lewscanon.com",
invert the top- and second-level domains and add your package name, like this:
com.lewscanon.example.package
which in most filesystems for most class loaders would correspond to the
relative path
com/lewscanon/example/package/
in which your Foo class bytecode would appear as
com/lewscanon/example/package/Foo.class
"Relative to what?" you ask? Great question - relative to the first classpath
element that has such a subdirectory.
These matters are covered in Sun's tutorial.
-- Lew
Nigel Wade - 29 Mar 2007 14:08 GMT
> Oliver Wong wrote:
>>> Did you try compiling the files while ensuring that the current
[quoted text clipped - 8 lines]
>
> Java has no "built-in class path", but your Windows box might.
"Linux" box...
There is a built-in class path, or at least a default which amounts to the same
thing:
Standard Options
-classpath classpath
Sets the user class path, overriding the user class path in the
CLASSPATH environment variable. If neither CLASSPATH or
-classpath is specified, the user class path consists of the
current directory.

Signature
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555