我在尝试运行Mapreduce Wordcount示例时遇到了这个问题:
Exception in thread "main" java.lang.ClassNotFoundException: /usr/local/hadoop/input
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.hadoop.util.RunJar.run(RunJar.java:214)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
我读到这是因为创建jar文件时我没有选择主文件。
这是我用来创建jar文件的命令供你参考:
javac -classpath /usr/local/hadoop/etc/hadoop:/usr/local/hadoop/share/hadoop/common/lib/* :/usr/local/hadoop/share/hadoop/common/* :/usr/local/hadoop/share/hadoop/hdfs:/usr/local/hadoop/share/hadoop/hdfs/lib/* :/usr/local/hadoop/share/hadoop/hdfs/* :/usr/local/hadoop/share/hadoop/yarn/lib/* :/usr/local/hadoop/share/hadoop/yarn/* :/usr/local/hadoop/share/hadoop/mapreduce/lib/* :/usr/local/hadoop/share/hadoop/mapreduce/* :/contrib/capacity-scheduler/*.jar -d wordcount_classes WordCount.java
基本上,我想我希望命令行等同于这个问题:question。
答案 0 :(得分:2)
尝试将清单文件用于主类,并使用以下步骤创建一个jar
在命令提示符中创建jar文件
Start Command Prompt.
Navigate to the folder that holds your class files:
C:\>cd \mywork
Set path to include JDK’s bin. For example:
C:\mywork> path c:\Program Files\Java\jdk1.7.0_25\bin;%path%
Compile your class(es):
C:\mywork> javac *.java
Create a manifest file and your jar file:
C:\mywork> echo Main-Class: Craps >manifest.txt
C:\mywork> jar cvfm Craps.jar manifest.txt *.class
or
C:\mywork> jar cvfe Craps.jar Craps *.class
Test your jar:
C:\mywork> Craps.jar
or
C:\mywork> java -jar Craps.jar