NoClassDefFoundError org/apache/poi/ss/usermodel/Workbook
<p>I am running a shell script which calls a java class to get some data from database and create an excel report with that data. I get the error Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Workbook when the code hits the below line in my java class:</p>

<pre><code>XSSFWorkbook  workbook = new XSSFWorkbook ();
</code></pre>

<p>This is how I have defined the classpath:</p>

<pre><code>CLASSPATH=${CLASSPATH}:&lt;path-to-jars&gt;/poi-2.5.1-final-20040804.jar
CLASSPATH=${CLASSPATH}:&lt;path-to-jars&gt;/poi-ooxml-3.11.jar
</code></pre>

<p>I verified that the jars have been downloaded(via gradle), so trying to understand what am I missing here. Can someone please help me with this?</p>

<p>Stacktrace:</p>

<pre><code>    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Workbook
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        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)
        at com.test.ExcelReportGenerator.writeExcel(ExcelReportGenerator.java:26)
        at com.test.ReportRunner.createReport(ReportRunner.java:109)
        at com.test.ReportRunner.main(ReportRunner.java:93)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.Workbook
        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)
        ... 15 more
</code></pre>