java local_java – 在Local中执行示例Flink程序

我试图在本地模式下在Apache 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值