java 编译hadoop java文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15267647/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 19:02:43  来源:igfitidea点击:

Compiling hadoop java files

javahadoopmapreduce

提问by BinaryMee

I need to compile Java Hadoop programs.

我需要编译 Java Hadoop 程序。

I have compiled and got .class files for mapper and reducer.

我已经编译并获得了映射器和减速器的 .class 文件。

But when I compile mainjava file, i keep getting this error.

但是当我编译 mainjava 文件时,我不断收到这个错误。

enter image description herethat is it can't point mapper and reducer class files.

在此处输入图片说明那就是它不能指向 mapper 和 reducer 类文件。

How can I resolve this issue?

我该如何解决这个问题?

回答by Alper

You have to give all of your source files to javac

您必须将所有源文件都提供给 javac

Example:

例子:

 javac -classpath /usr/local/hadoop/hadoop-core-1.0.4.jar -sourcepath src/ -d build/ MyMain.java MyMapper.java MyReducer.java

回答by Chong Tang

hadoop-core-${VERSION}.jar is in ${HADOOP_HOME}/share/common directory.

hadoop-core-${VERSION}.jar 位于 ${HADOOP_HOME}/share/common 目录中。

javac --classpath=${HADOOP_HOME}/share/common/hadoop-core-${HADOOP_VERSION}.jar YourClass.java

will do the work.

会做的工作。