我正在尝试使用以下命令编译基本的MapReduce Wordcount示例:
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
这会引发以下错误:
javac: invalid flag: :/usr/local/hadoop/share/hadoop/common/*
Usage: javac <options> <source files>
use -help for a list of possible options
但是当我以某种明智的方式列出时,即。首先指定
commons
jar文件
javac -classpath /usr/local/hadoop/share/hadoop/common/hadoop-common-2.7.3.jar -d wordcount_classes/ WordCount.java
它显示了代码的常规编译错误,即
WordCount.java:9: error: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.*;
^
WordCount.java:13: error: cannot find symbol
public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
^
symbol: class MapReduceBase
location: class WordCount
WordCount.java:13: error: cannot find symbol
public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
^
symbol: class Mapper
location: class WordCount
WordCount.java:17: error: cannot find symbol
public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
^
symbol: class OutputCollector
location: class Map
WordCount.java:17: error: cannot find symbol
public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
....(more errors then finally -->) 16 errors found
当我使用原始的巨大classpath命令执行此操作时,我的程序编译没有错误。有人可以告诉我为什么会发生这种情况以及我如何使用多个类路径行一次编译文件而不必采用这种明智的方法?