title: Commons Math: java.lang.ClassNotFoundException
body: <p>I have this tiny bit of Java code:</p>
  
  <pre><code>import java.io.*;
  import org.apache.commons.math3.linear.*;
  
  class Test
  {
      public static void main(String[] args){
          RealVector alpha= MatrixUtils.createRealVector(new double[10]);
          System.out.println(alpha.getEntry(0));      
      }
  }
  </code></pre>
  
  <p>I can compile it successfully using <code>javac Test.java -cp .;commons-math.jar</code>
  But when I try to run it using <code>java Test -cp .;commons-math.jar</code>, it throws up this:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/ma
  th3/linear/MatrixUtils
          at Test.main(Test.java:9)
  Caused by: java.lang.ClassNotFoundException: org.apache.commons.math3.linear.Mat
  rixUtils
          at java.net.URLClassLoader$1.run(Unknown Source)
          at java.security.AccessController.doPrivileged(Native Method)
          at java.net.URLClassLoader.findClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
          at java.lang.ClassLoader.loadClass(Unknown Source)
          ... 1 more
  </code></pre>
  
  <p>From the Googling I did, a <code>ClassNotFoundException</code> usually occurs when your classpath isn't pointing to the right location. But since my code compiles, I don't see why it shouldn't execute. Any ideas?</p>