would you please explain how to put classes in package and to use them.
I make a directory name One. And two classes: Class1 and Class2 in the
directory, One.
Class1.java:7: cannot find symbol
symbol : class Class2
location: class One.Class1
Class2 test = new Class2();
^
Class1.java:7: cannot find symbol
symbol : class Class2
location: class One.Class1
Class2 test = new Class2();
^
2 errors
Class2 compiled ok, but not Class1. The following is error while compiling
Class 1.
Class1.java:7: cannot find symbol
symbol : class Class2
location: class One.Class1
Class2 test = new Class2();
^
Class1.java:7: cannot find symbol
symbol : class Class2
location: class One.Class1
Class2 test = new Class2();
^
2 errors
================
==============
/ * filename Class1.java */
package One;
public class Class1
{
public static void main(String args[])
{
Class2 test = new Class2();
}
}
=============
/* filename: Class2.java */
package One;
public class Class2
{
public static void main(String args[])
{
}
}
Knute Johnson - 11 Jun 2005 22:52 GMT
> would you please explain how to put classes in package and to use them.
> I make a directory name One. And two classes: Class1 and Class2 in the
> directory, One.
thanh:
You need to think of packages as directories. The package one.two.three
would be in directory one/two/three. So to compile files in any of the
packages you need to be in a directory above one (eg. root).
This and how jar files work is one of the most complicated parts of
Java. Why it isn't simpler or better documented I don't know.

Signature
Knute Johnson
email s/nospam/knute/