IDEA 创建第一个 Flink 项目 出现JNI错误

问题描述

跑flink源码无任何问题,但是自己创建一个新的flink项目就会出现错误

Error: A JNI error has occurred, please check your installation and try again

问题出现的环境背景及自己尝试过哪些方法

flink:1.8.0
jdk:1.8.0_221-b11
maven:3.6.2

1.搜索网上方法无法解决

版本一样

2.https://kb.froglogic.com/squish/java/howto/use-java-web-start-squish/

相关代码

public class SocketWindowWordCount {  
  
   public static void main(String\[\] args) throws Exception {  
  
      StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();  
  DataStream text = env.socketTextStream("localhost", 9000, "\\n");  
  DataStream> windowCounts = text  
            .flatMap(new FlatMapFunction>() {  
               @Override  
  public void flatMap(String value, Collector> out) {  
                  for (String word : value.split("\\\\s")) {  
                     out.collect(Tuple2.of(word, 1));  
  }  
               }  
            })  
            .keyBy(0)  
            .timeWindow(Time.seconds(5))  
            .sum(1);  
  windowCounts.print().setParallelism(1);  
  env.execute("Socket Window WordCount");  
  }  
}

最佳答案

ClassNotFound
少了依赖,或者版本不对,直接搜索异常和后面的类名就行了