带有Apache Commons Math的NoClassDefFoundError [英] NoClassDefFoundError with Apache commons math

查看:129
本文介绍了带有Apache Commons Math的NoClassDefFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Apache Commons的PoissonDistribution,但总是收到 NoClassDefFoundError 错误.

I want to use the PoissonDistribution from Apache Commons but always get the error a NoClassDefFoundError.

代码:

import org.apache.commons.math3.distribution.PoissonDistribution;

public class Test {

    public static void main(String[] args) {
        PoissonDistribution p = new PoissonDistribution(5.0);

    }

}

错误消息:

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

到目前为止,我所做的是:commons-math3-3.6.1.jar文件位于我的项目文件夹中的一个文件夹中,并通过 Project-> Properties-> Java Build Path-> Libraries 添加了JAR文件,然后在其旁边的订购和出口"标签中,选择了jar文件.

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.

感谢您的帮助!

推荐答案

好的,巧合的是,我找到了解决方法:

Ok so by coincidence I've found the solution:

我的问题是我将JAR添加到了项目属性中的Modulepath中,而不是Classpath中.

My problem was that I added the JAR to the Modulepath and not the Classpath in the project properties.

这篇关于带有Apache Commons Math的NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆