2013-04-05 204 views
0

我刚刚开始学习hadoop 1.1.2。hadoop jar命令的类名是否区分大小写?

当我开始运行WordCount的情况下,这两种代码都很好。

指令A:

hadoop jar /usr/local/hadoop/hadoop-examples-1.1.2.jar WordCount input output 

命令B:

hadoop jar /usr/local/hadoop/hadoop-examples-1.1.2.jar wordcount input output 

唯一的区别是主类名wordcount

所以我的问题是天气主要类名wordcount大小写忽略或不默认?

更新

@Amar说WordCount将无法​​正常工作,我已经检查了他是正确的。我被文件here误导了。官方文件需要更新。

但我仍然不知道为什么它必须是wordcount

回答

3

尝试运行没有wordcount,如: hadoop jar /usr/local/hadoop/hadoop-examples-1.1.2.jar input output

像下面你将得到的东西:

Unknown program 'input' chosen. 
Valid program names are: 
    aggregatewordcount: An Aggregate based map/reduce program that counts the words in the input files. 
    aggregatewordhist: An Aggregate based map/reduce program that computes the histogram of the words in the input files. 
    dbcount: An example job that count the pageview counts from a database. 
    grep: A map/reduce program that counts the matches of a regex in the input. 
    join: A job that effects a join over sorted, equally partitioned datasets 
    multifilewc: A job that counts words from several files. 
    pentomino: A map/reduce tile laying program to find solutions to pentomino problems. 
    pi: A map/reduce program that estimates Pi using monte-carlo method. 
    randomtextwriter: A map/reduce program that writes 10GB of random textual data per node. 
    randomwriter: A map/reduce program that writes 10GB of random data per node. 
    secondarysort: An example defining a secondary sort to the reduce. 
    sleep: A job that sleeps at each map and reduce task. 
    sort: A map/reduce program that sorts the data written by the random writer. 
    sudoku: A sudoku solver. 
    teragen: Generate data for the terasort 
    terasort: Run the terasort 
    teravalidate: Checking results of terasort 
    wordcount: A map/reduce program that counts the words in the input files. 

所以基本上第一个参数不是主要的类名,而这是示例程序的名称,你想运行。

所以,它甚至不应该接受WordCount,它不适合我。 下面的命令具有相同的结果,如图以上:

bin/hadoop jar hadoop-examples-1.0.4.jar WordCount LICENSE.txt output


为了您的信息:主要级在包含在罐中的META-INF/MANIFEST.MF文件已经定义: Main-Class: org/apache/hadoop/examples/ExampleDriver

+0

该文档[此处](http://hadoop.apache.org/docs/r1.1.2/commands_manual.html#jar)表示用法为'用法:hadoop jar [mainClass] args ...',所以' wordcount'应该是'mainClass'。我再次检查,发现'WordCount'不能正常工作。但文档[这里](http://hadoop.apache.org/docs/r1.1.2/mapred_tutorial.html#Usage)误导了我。 – Huo 2013-04-05 12:25:20

+0

上面的答案究竟是什么,你不明白? – Amar 2013-04-05 15:13:39

+0

只有在你的jar清单中没有指定它时,你才需要指定mainclass。文档中的方括号表明它是可选的。这是一个不同的罐子!在这种情况下,这个jar期望的第一个参数是示例程序的名称(例如treasort,wordcount等)。简单。 – Amar 2013-04-05 15:19:32

0

它肯定是区分大小写的,因为它试图从jar中加载类WordCountwordcount,具体取决于套管。由于Java在这方面区分大小写,所以hadoop jar也是如此。

+0

我解压缩了hadoop-examples-1.1.2.jar文件,并且没有发现小写的“wordcount”类。 – Huo 2013-04-05 05:22:17

+0

而你可能不应该。它可能是名为WordCount.java的文件中名为WordCount的类。 – sidoh 2013-04-05 05:28:49

+0

所以班级名称是“WordCount”,而不是“wordcount”。 “命令B”如何正常工作? – Huo 2013-04-05 05:33:58