title: "error: cannot find symbol" when compiling with javac using makefile
body: <p>My directory currently looks like this</p>
  
  <pre><code>├── Makefile
  ├── run_tests (Unix executable)
  └── src
      └── vehicles
          ├── Wheels.java
          └── Cars.java
      └── RunProgram.java
      tests
      └── test1.txt
      └── test2.txt
  </code></pre>
  
  <p><strong>RunProgram.java is my main.</strong> </p>
  
  <p>Looking online, I currently have a Makefile that looks like this:</p>
  
  <pre><code>JFLAGS = -g
  JC = javac
  .SUFFIXES: .java .class
  .java.class:
      $(JC) $(JFLAGS) $*.java
  
   CLASSES = \
      src/vehicles/Wheels.java \
      src/vehicles/Cars.java \
      src/RunProgram.java 
  
  default: classes
  
  classes: $(CLASSES:.java=.class)
  
  clean:
      $(RM) *.class
  </code></pre>
  
  <p>I have two main issues right now.</p>
  
  <p><strong>1.</strong> Cars.java throws an "error: cannot find symbol" for Wheels even though it compiles Wheels first (previously I had the order wrong, now it's correct).</p>
  
  <p><strong>2.</strong> I'm going to need to add a "test" to the Makefile eventually, which comes with its own problems. Essentially run_tests will put everything in the tests folder through System.in. However it has trouble running things in another directory, so I have to output the RunProgram.class to the root directory.</p>
  
  <p><strong>THIS IS HOW I RAN THE TESTS FROM THE COMMAND LINE WHEN THE ONLY PROGRAM IN THE PACKAGE STRUCTURE WAS RunProgram.java</strong></p>
  
  <pre><code>javac -d ./ ./src/RunProgram.java 
  ./run_tests "java RunProgram"
  </code></pre>
  
  <p>However, when I try running javac now I get errors that package imports don't exist. This is why I'm going with Makefile, as that's the ideal solution.</p>
  
  <p><strong>TL;DR</strong> I need a way to compile my program with Makefile and write a "make test" command that can properly call run_tests</p>
  
  <p><strong>I'm also willing to accept a solution that allows me to run javac from the command line and run the the tests from there, but Makefile is preferred</strong></p>