When you compile things, all packge names are relative to the items in the "sourcepath". The default source path is ".", the current directory.
so:
$ mkdir myproject
$ cd myproject
$ mkdir apackage
$ cd apackage
$ echo "package apackage; class Foo {}" > Foo.java
$ cd ..
$ javac apackage/Foo.java
$ java -classpath . apackage.Foo
ERRROR class Foo has no main() method, you tool!
$
> it was helpful but it didn't answer all my questions
> where do you put the file?
You can put it wherever it is convenient, as long as the directory structure and Classpath are correct. For example, you might want to keep the .class files separate from the .java files. For a Windows machine you could create a directory c:\myjava\myclasses and c:\myjava\mysources. Then put your projects into the mysources directory. You can use the -d option of javac to compile your code into the myclasses directory. If you put c:\myjava\myclasses into your system Classpath, then everything will work.
> can you put it in the src.zip folder?
I wouldn't. If you upgrade the j2sdk, then you will get a new src.zip. You can put packages into jar files.
> do you have to compile it so it will be in the
> package?
By putting the package statement into the source code, it will be compiled as a packaged class. However, it must be in the correct directory structure to use the class. You can put the source into the right directory and the compiler will generate the .class file there. Or you can use the -d option of javac. Or you can manually move files to the right directory. As long as the .class file
> can you put two package statements in the same file?
No. Packages are used to manage access and namespaces. A class has a fully qualified class name which is used to uniquely identify the class. The fully qualified class name is the package name plus the class name.