MapReduce项目如何输出jar包
程序打包:(只要yarn jar命令可以运行, 这里就一定能运行)马克- to-win:马克 java社区:防盗版实名手机尾号: 73203。
右键单击工程,点开“Export…”,在弹出的对话框中选择“java/JAR file”,
马克- to-win:马克 java社区:防盗版实名手机尾号: 73203。
这样就会生成到项目的根目录的上一层,针对生成的“WordCount.jar”,通过以下命令执行程序:
hadoop jar WordCount.jar /README.txt /output4
以下为结果:
K:\eclipse-workspace>hadoop jar WordCount.jar /README.txt /output4
19/03/02 17:38:46 INFO Configuration.deprecation: session.id is deprecated. Inst
ead, use dfs.metrics.session-id
解释:jar文件中只有.class文件,还有一个.classpath文本文件,里面记录着:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="D:/hadoop-2.7.4/share/hadoop/yarn/lib/zookeeper-3.4.6.jar"/>
<classpathentry kind="lib" path="D:/hadoop-2.7.4/share/hadoop/yarn/lib/zookeeper-3.4.6-tests.jar"/>
<classpathentry kind="lib" path="D:/hadoop-2.7.4/share/hadoop/yarn/lib/xz-1.0.jar"/>
<classpathentry kind="lib" path="D:/hadoop-2.7.4/share/hadoop/yarn/lib/stax-api-1.0-2.jar"/>
<classpathentry kind="lib" path="D:/hadoop-2.7.4/share/hadoop/yarn/lib/servlet-api-2.5.jar"/>
<classpathentry kind="lib" path="D:/hadoop-2.7.4/share/hadoop/yarn/lib/protobuf-java-2.5.0.jar"/>
<classpathentry kind="lib" path="D:/hadoop-2.7.4/share/hadoop/yarn/lib/netty-3.6.2.Final.jar"/>
<classpathentry kind="lib" path="D:/hadoop-2.7.4/share/hadoop/yarn/lib/log4j-1.2.17.jar"/>
<classpathentry kind="lib" path="D:/hadoop-2.7.4/share/hadoop/yarn/lib/leveldbjni-all-1.8.jar"/>
<classpathentry kind="lib" path="D:/hadoop-2.7.4/share/hadoop/yarn/lib/jsr305-3.0.0.jar"/>
。。。。。
这就是能运行起来的原因。