Java Packages: Newbie on modifying system default package to a named package
<p>I'm new to java and packages and need some help navigating them. Currently I have a functioning java program for a web application where all my .java and .class files sit in the <code>myapp/WEB-INF/classes</code> directory on a linux server:</p>

<pre><code>myapp/WEB-INF/classes/MyJavaClass1.class
myapp/WEB-INF/classes/MyJavaClass2.class
myapp/WEB-INF/classes/MyJavaClass3.class
</code></pre>

<p>None of these files include a line of code for <code>package</code> so I assume the system default package is being used. </p>

<p>Then I added a <code>mytools</code> directory, and created a new class in there. </p>

<pre><code>myapp/WEB-INF/classes/mytools/MyToolClass1.class
</code></pre>

<p>But it seems like this new class cannot access the classes in the <code>myapp/WEB-INF/classes</code> directory unless those java files include a package name. So my question is how to change the files to go from a system default package (e.g. no package specified) to a named package?</p>

<p>Should I append <code>package mypackage;</code> to the first line of MyJavaClass1.java, MyJavaClass2.java, and MyJavaClass3.java, and append <code>package mypackage.mytools;</code> to MyToolClass1.java? </p>

<p>Or, do I also need to create a directory <code>mypackage</code> such that <code>myapp/WEB-INF/classes/mypackage</code> and place the files MyJavaClass1.class etc. in there, before doing the above?</p>

<p>Then when I compile the .java files, do I compile each within their own directory (or do all files need to be compiled from top level directory)?</p>

<p>UPDATE 1</p>

<p>If I simply keep the default package (i.e. no package) for the java files in <code>myapp/WEB-INF/classes</code>, and append:</p>

<pre><code>package mytools;
import MyJavaClass1;
</code></pre>

<p>to MyToolClass1.java and try to compile MyToolClass1.java from the <code>mytools</code> directory, I get the following compile errors:</p>

<pre><code>MyToolClass1.java:21: '.' expected
import MyJavaClass1;
                   ^
MyToolClass1.java:21: ';' expected
import MyJavaClass1;
                    ^
2 errors
</code></pre>
