title: Getting NoClassDefFoundError when running JasperReports based application from command line
body: <p>For the whole day I have been trying to run my first report based on the JasperReports library, but I am yet to get my desired result.</p>
  
  <p>I have a <code>ReportTemplate.jrxml</code> file containing:</p>
  
  
  
  <pre><code>&lt;!DOCTYPE jasperReport
    PUBLIC "-//JasperReports//DTD Report Design//EN"
    "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"&gt;
  
  &lt;jasperReport name="Simple_Report"&gt;
   &lt;detail&gt;
      &lt;band height="20"&gt;
        &lt;staticText&gt;
          &lt;reportElement x="180" y="0" width="200" height="20"/&gt;
          &lt;text&gt;&lt;![CDATA[Hello World!]]&gt;&lt;/text&gt;
        &lt;/staticText&gt;
      &lt;/band&gt;
    &lt;/detail&gt;
  &lt;/jasperReport&gt;
  </code></pre>
  
  <p>and my <code>.java</code> file:</p>
  
  <pre><code>import net.sf.jasperreports.engine.JasperReport;
  import net.sf.jasperreports.engine.JasperCompileManager;
  import net.sf.jasperreports.engine.JasperPrint;
  import net.sf.jasperreports.engine.JasperFillManager;
  import net.sf.jasperreports.engine.JREmptyDataSource;
  import net.sf.jasperreports.engine.JasperExportManager;
  import net.sf.jasperreports.engine.JRException;
  import java.util.HashMap;
  
  public class TestReport {
      public static void main(String[] args)  {
          HashMap&lt;String, Object&gt; hm = new HashMap&lt;&gt;();
          JREmptyDataSource ds = new JREmptyDataSource();
          JasperReport jasperReport;
          JasperPrint jasperPrint;
          try {
              jasperReport = JasperCompileManager.compileReport("ReportTemplate.jrxml");
              jasperPrint = JasperFillManager.fillReport(jasperReport, hm, ds);
              JasperExportManager.exportReportToPdfFile(
              jasperPrint, "reports/simple_report.pdf");
          } catch (JRException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>Both locate in the same directory. So, let's go</p>
  
  <pre><code>D:\Java\Applecation\Report&gt;javac -classpath D:\JasperReports\jasperreports-5.5.0\dist\jasperreports-5.5.0.jar TestReport.java
  D:\Java\Applecation\Report&gt;_
  </code></pre>
  
  <p>works!</p>
  
  <pre><code>D:\Java\Applecation\Report&gt;java -classpath D:\JasperReports\jasperreports-5.5.0\dist\jasperreports-5.5.0.jar TestReport
  Error: Could not find or load main class TestReport
  </code></pre>
  
  <p>try simply</p>
  
  <pre><code>D:\Java\Applications\ATConsulting\report&gt;java TestReport
  Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/jasperreports/
  engine/JRException
          at java.lang.Class.getDeclaredMethods0(Native Method)
          at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
          at java.lang.Class.getMethod0(Class.java:2764)
          at java.lang.Class.getMethod(Class.java:1653)
          at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
          at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
  
  Caused by: java.lang.ClassNotFoundException: net.sf.jasperreports.engine.JRExcep
  tion
          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:424)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          ... 6 more
  </code></pre>
  
  <p>Sorry if it's dumb question, I'm just beginner.</p>
  
  <p>Thanks for any help!</p>