title: Class not found when running program from command line
body: <p>Here is the structure of my project:</p>
  
  <pre><code>MyProject
  -lib
     -mp3agic-0.9.0.jar
  
  -src
     -com.company
        -Main.java
  </code></pre>
  
  <p>Inside Main, I import the content of mp3agic:</p>
  
  <p>import com.mpatric.mp3agic.*;</p>
  
  <p>From MyProject, I compile the class using:</p>
  
  <p>javac -cp "lib/*" src/com/company/Main.java</p>
  
  <p>From MyProject/src, I try to run the program with:</p>
  
  <p>java -cp . com/company/Main</p>
  
  <p>and I get the following error:</p>
  
  <p>Exception in thread "main" java.lang.NoClassDefFoundError: com/mpatric/mp3agic/InvalidDataException</p>
  
  <p>Apparently, the jdk can not find the dependencies from the lib folder when running the class, albeit this problem doesn't occur when compiling.
  I guess there's a problem with the syntax of the command, but I just can't find it.</p>
  
  <p>Can you please help me?</p>
  
  <p>EDIT: I solved the problem, moving the lib folder under src and then running:</p>
  
  <p>C:\MyProject\src>javac -cp "lib/*" com/company/Main.java</p>
  
  <p>C:\MyProject\src>java -cp .;"lib/*" com/company/Main</p>
  
  <p>Now, the code compiles and executes without any issue.</p>
  
  <p>HOWEVER, if I leave lib under the project root, this is what happens:</p>
  
  <p>C:\MyProject>javac -cp "lib/*" src/com/company/Main.java </p>
  
  <p>C:\MyProject>java -cp .;"lib/*" src/com/company/Main </p>
  
  <p>Error: Could not find or load main class src.com.company.Main</p>
  
  <p>WHY?</p>