title: How to fix java.lang.NoClassDefFoundError in Netbeans?
body: <p>I'm developing a library (fpotencia) wich I use from a GUI program (fpotenciaui).
  The library uses the <code>commons math</code> library.</p>
  
  <p>When I run the GUI program I get:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/math3/complex/Complex
      at fpotencia.Circuit.&lt;init&gt;(Circuit.java:101)
      at gui.MainGUI.&lt;init&gt;(MainGUI.java:34)
      at fpotenciaui.FPotenciaUI.main(FPotenciaUI.java:53)
  Caused by: java.lang.ClassNotFoundException: org.apache.commons.math3.complex.Complex
      at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
      ... 3 more
  Java Result: 1
  </code></pre>
  
  <p>I have read in <a href="https://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java?rq=1">here</a> that this is due to the presence of the library at design time but not at run time.</p>
  
  <p>I have also read <a href="https://stackoverflow.com/questions/1551697/getting-java-lang-classnotfoundexception-org-apache-commons-logging-logfactory">here</a> that I need to include the library <code>commons-logging.jar</code> from <a href="http://commons.apache.org/proper/commons-logging/download_logging.cgi" rel="nofollow noreferrer">here</a>, which I have done for both the libary and the UI projects.</p>
  
  <p>I would like to be able to include whatever I need from Netbeans since when I share the code with others I do not want them to have to do things like including libraries in the path. I am electrical engineer and I find very messy having to do such things "manually", besides, why is Netbeans for if I have to include libraries in the path from the command line?</p>
  
  <p>So my question is, why does Netbeans not sort this problem out if I am clearly including the library in the project?</p>
  
  <p>PS: maybe I'm misunderstanding the problem, if so, I'd appreciate some guidance to get this solved. Thanks.</p>