flink 本地_在本地执行示例Flink程序

我试图在本地模式下执行Apache Flink中的示例程序。在本地执行示例Flink程序

import org.apache.flink.api.common.functions.FlatMapFunction;

import org.apache.flink.api.java.DataSet;

import org.apache.flink.api.java.ExecutionEnvironment;

import org.apache.flink.api.java.tuple.Tuple2;

import org.apache.flink.util.Collector;

public class WordCountExample {

public static void main(String[] args) throws Exception {

final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();

DataSet text = env.fromElements(

"Who's there?",

"I think I hear them. Stand, ho! Who's there?");

//DataSet text1 = env.readTextFile(args[0]);

DataSet> wordCounts = text

.flatMap(new LineSplitter())

.groupBy(0)

.sum(1);

wordCounts.print();

env.execute();

env.execute("Word Count Example");

}

public static class LineSplitter implements FlatMapFunction> {

@Override

public void flatMap(String line, Collector> out) {

for (String word : line.split(" ")) {

out.collect(new Tuple2(word, 1));

}

}

}

}

这是给我的例外:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/mapreduce/InputFormat

at WordCountExample.main(WordCountExample.java:10)

Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.mapreduce.InputFormat

at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

at java.lang.ClassLoader.loadClass(ClassLoader.java:425)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

... 1 more

我在做什么错?

我也使用了正确的罐子。 弗林克的Java-0.9.0-里程碑 - 1.jar 弗林克的客户端-0.9.0-里程碑 - 1.jar 弗林克核-0.9.0-里程碑 - 1.jar

+0

你到底该如何执行程序?您是通过CLI客户端还是Web提交客户端从IDE运行它? –

+0

我正在从IDE运行它,将它作为普通的Java应用程序运行。 –

+0

正如文档中给出的那样,我可以在本地模式下直接在桌面上运行它 –

你可能感兴趣的:(flink,本地)