title: Refer class in another .java file in my program
body: <p>I am absolutely new to Java and having trouble referencing a class that I have declared in another .java file. I read a lot about it on the Oracle Website and also many stackoverflow questions, but couldn't solve the problem. Here are the steps I have taken:</p>
  
  <p><strong>Set the class path.</strong>
  I am running this on UNIX. So I typed in
  <code>% java -classpath /users/myUserName/algs4/assignment1</code>. Instead of changing the class path it gives me a long list of other options. </p>
  
  <p><strong>Include the 'package name'</strong> in each of my .java files which have class definitions I want to refer to.</p>
  
  <p>I also ensured that all my files that I want to refer are in the same directory. 
  Here is some of my code:</p>
  
  <pre><code>package assignment1;
  public class Percolation
  {
      private int[][] grid;
      ....
      //Other method definitions etc.
     public Percolation(int N)
     {
        uf = new WeightedQuickUnionUF(N);
        grid = new int[N][N];
        ...
        //Other code
  
     }
  
   }
  </code></pre>
  
  <p>My WeightedQuickUnionUF class is also defined as:</p>
  
  <pre><code>package assignment1;
  public class WeightedQuickUnionUF {
      private int[] id;    // id[i] = parent of i
      private int[] sz;    // sz[i] = number of objects in subtree rooted at i
      private int count;   // number of components
  
      //Create an empty union find data structure with N isolated sets.
      public WeightedQuickUnionUF(int N) {
          count = N;
          id = new int[N];
          sz = new int[N];
          for (int i = 0; i &lt; N; i++) {
              id[i] = i;
              sz[i] = 1;
          }
       }
  }
  </code></pre>
  
  <p>But now when I compile using javac Percolation.java. It gives me the errors:</p>
  
  <pre><code>Percolation.java:7: cannot find symbol
  symbol  : class WeightedQuickUnionUF
  location: class assignment1.Percolation
  WeightedQuickUnionUF uf;
  ^
  </code></pre>
  
  <p>I get it that it is because the compiler doesn't know what is the class WeightedQuickUnionUF. It cannot refer it. But how do I do it then? I have already tried the popular solutions. </p>
  
  <p>I am not using any IDE. Just a text editor and then compiling it on the terminal.</p>
  
  <p>(algs4 folder has files like stdlib.jar and others)</p>
  
  <p>EDIT: I missed the 'new' keyword. I have added that. Also I am compiling my WeightedQuickUnionUF class before Percolation.java</p>