Issue
I want to use the PoissonDistribution from Apache Commons but always get the error a NoClassDefFoundError
.
The code:
import org.apache.commons.math3.distribution.PoissonDistribution;
public class Test {
public static void main(String[] args) {
PoissonDistribution p = new PoissonDistribution(5.0);
}
}
The error message:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/math3/distribution/PoissonDistribution
at Test.main(Test.java:6)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.math3.distribution.PoissonDistribution
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 1 more
What I've done so far:
The commons-math3-3.6.1.jar file is located in a folder inside my project folder and via Project->Properties->Java Build Path->Libraries
I added the JAR file and then in the "Order and Export" tab next to it I selected the jar file.
Thanks for your help!
Solution
Ok so by coincidence I've found the solution:
My problem was that I added the JAR to the Modulepath and not the Classpath in the project properties.
Answered By - niko