title: How to compile java package structures using javac
body: <p>I am trying to compile (from the command line) a java package that imports another package of my own. I was following a <a href="http://www.roseindia.net/java/master-java/createsubpackage.shtml" rel="noreferrer">tutorial online</a> but it seems that I get an error when I try to compile the final java file (CallPackage.java). </p>
  
  <p>Here is the file structure:</p>
  
  <pre><code>+ test_directory (contains CallPackage.java)
     -&gt; importpackage
         -&gt; subpackage (contains HelloWorld.java)
  </code></pre>
  
  <p>Here is CallPackage.java:</p>
  
  <pre><code>/// CallPackage.java
  import importpackage.subpackage.*;
  class CallPackage{
    public static void main(String[] args){
    HelloWorld h2=new HelloWorld();
    h2.show();
    }
  }
  </code></pre>
  
  <p>and here is HelloWorld.java:</p>
  
  <pre><code>///HelloWorld.java
  
  package importpackage.subpackage;
  
  public class HelloWorld {
    public void show(){
    System.out.println("This is the function of the class HelloWorld!!");
    }
  }
  </code></pre>
  
  <h2>Attempted Steps</h2>
  
  <ol>
  <li>Go to the subpackage and compile HelloWorld.java with <code>$javac HelloWorld.java</code>.</li>
  <li>Go to test_directory and compile CallPackage.java with <code>$javac CallPackage.java</code>.</li>
  </ol>
  
  <p>This gives me an error on the last command:</p>
  
  <pre><code>CallPackage.java:1: package importpackage.subpackage does not exist
  import importpackage.subpackage.*;
  ^
  CallPackage.java:4: cannot find symbol
  symbol  : class HelloWorld
  location: class CallPackage
    HelloWorld h2=new HelloWorld();
    ^
  CallPackage.java:4: cannot find symbol
  symbol  : class HelloWorld
  location: class CallPackage
    HelloWorld h2=new HelloWorld();
                      ^
  3 errors
  </code></pre>
  
  <p>How can I compile both packages? Thanks so much for any help!</p>