結論:
1,簡單的hadoop項目(Maven)在Create JAR from Modules頁面中,最簡單的方式為Main Class為空,選擇extract to the target JAR。這樣不會指定主類,不會生成MANIFEST.MF文件。
2,Main Class會在jar包內的MANIFEST.MF中指定主類,執行jar包時不可以另外指定主類。
3,選項extract to the target JAR(提取到目標JAR)不會在MANIFEST.MF文件中鏈接依賴的jar包(整包)。
選項copy to the output directory and link via manifest(復制到輸出目錄和清單鏈接)會將依賴的jar包放在目錄中,在MANIFEST.MF文件中以鏈接的形式引用jar包(散包)。
Create JAR from Modules頁面
一
NO Main Class
extract to the target JAR
hadoop jar WordCount.jar WordCount input/demo/word.txt output
成功
二
Main Class
extract to the target JAR
hadoop jar WordCount.jar input/demo/word.txt output
成功
三
NO Main Class
copy to the output directory and link via manifest
失敗 Exception in thread "main" java.lang.ClassNotFoundException: 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) hadoop jar WordCount.jar WordCount input/demo/word.txt output 刪除MANIFEST.MF文件成功
四
Main Class
copy to the output directory and link via manifest
hadoop jar WordCount.jar input/demo/word.txt output
成功