title: Java: Setting Classpath
body: <p>I have a project due soon and everything is coming together really nicely, but java classpaths are getting seriously in the way. I'll try to explain the situation as clearly and thoroughly as I can.</p>
  
  <p>So we are using Javacc to write a programming language. The javacc file compiles into several java files. The Parser.java file includes references and calls to the other generated java files. So, after generation, we compile the Parser.java file. The problem is we get many errors, including not being able to recognize the calls to the other java files as well as our own files. <strong>We asked on a classroom discussion board about our problem and the professor responded with "you need to have the class files in your classpath". Ok, great, so the question is, how do we do that?</strong> Basically we have a single directory with the generated java files and our other helper files. </p>
  
  <p><strong>So, what have we tried?</strong></p>
  
  <p>I have tried changing my .bashrc (Ubuntu) file to include the correct classpath but that doesn't work. i.e.</p>
  
  <pre><code> CLASSPATH=Home/project
  </code></pre>
  
  <p>(something like that I had the syntax right in the file)</p>
  
  <p>I've tried on compilation executing</p>
  
  <pre><code>javac -cp . Parser.java
  </code></pre>
  
  <p>and</p>
  
  <pre><code>javac -cp "." Parser.java
  </code></pre>
  
  <p>neither works.</p>
  
  <p>I have tried to edit the xml (I think xml) .classpath file in the directory of our files. Still doesn't work.</p>
  
  <p>Somehow, I was able to compile Parser.java in one of the directories I have (we ended up making multiple directories with the same files in it in a futile effort to make something work) but when I try to run</p>
  
  <pre><code>java -cp . Parser.java
  </code></pre>
  
  <p>or</p>
  
  <pre><code>java Parser.java
  </code></pre>
  
  <p>It says it can not find the main and throws (I believe, its on my other computer) ClassNotFound or ClassNotDefined exception (something like that, it cannot find the main in the Parser file eventhough it IS there). </p>
  
  <p>We have tried adding packages deceleration and import statements to our file, nothing seems to work.</p>
  
  <p><strong>BASICALLY: How can I successfully change the Classpath so that my java files (all in one directory and not jarred) can be compiled and run on my machine?</strong></p>
  
  <p>Thank you for your help. I greatly appreciate it.</p>