当前位置: 首页 > 知识库问答 >
问题:

IntelliJ错误:发生JNI错误,请检查您的安装并重试

郎恺
2023-03-14

我试图在intellij中运行一个项目,每次我运行一个特定的类,我都会得到下面的错误消息:

*Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/streaming/StreamingContext
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.spark.streaming.StreamingContext
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)**

共有2个答案

东郭凯捷
2023-03-14

您必须使用spark版本将spark流依赖项添加到SBT中:

库依赖="org.apache.spark " %% "火花流"%"你的火花版本"

任文乐
2023-03-14

我在很长一段时间里都面临着同样的问题,我的代码在执行以下代码时出现了同样的错误:

val ssc = new StreamingContext(sc, Seconds(10))

我的POM. xml看起来像这样:

<dependency>
      <groupId>org.apache.spark</groupId>
      <artifactId>spark-streaming_2.11</artifactId>
      <version>2.3.4</version>
      <scope>provided</scope>
</dependency>

你看到了那行额外的代码了吗

因此,请确保删除

    <dependency>
        <groupId>org.apache.spark</groupId>
        <artifactId>spark-streaming_2.11</artifactId>
        <version>2.3.4</version>
    </dependency>

 类似资料: