NoClassDefFoundError 与 Apache 公共数学 [英] NoClassDefFoundError with Apache commons math

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

问题描述

我想使用 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 添加到模块路径而不是项目属性中的类路径.

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

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

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