title: Troubleshoot NoClassDefFoundError in Java
body: <p>I have a Java program called Main.java, it is located in the following directory:</p>
  
  <pre><code>/home/user/program/Main.java
  </code></pre>
  
  <p>When I try to run Main.java from the 'program' directory, everything goes ok, I use this line:</p>
  
  <pre><code>/home/user/program$ java Main
  </code></pre>
  
  <p>But when I try to run Main.java from the home directory :</p>
  
  <pre><code>/home$ java /home/user/program/Main
  </code></pre>
  
  <p>I get :</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: /home/user/program/Main
  Caused by: java.lang.ClassNotFoundException: .home.user.program.Main
  </code></pre>
  
  <p>What is the cause of this error?</p>