我正在研究一个 RHEL 英特尔集群,该集群已经安装了 hadoop,并被其他用户大量使用和测试。我正在尝试学习使用该框架,所以我从这里的教程开始:http: //hadoop.apache.org/docs/r0.17.0/mapred_tutorial.html
所以,我从上面的链接中复制了 WordCount.java 的源代码到 ~/hadooptest/,并按照编译说明进行了一些小的更改以修复版本错误,这里是编译尝试的输出以及一些相关的系统信息。
[X@X hadooptest]$ pwd
/home/X/hadooptest
[X@X hadooptest]$ javac -version
Eclipse Java Compiler v_677_R32x, 3.2.1 release, Copyright IBM Corp 2000, 2006. All rights reserved.
[X@X hadooptest]$ $JAVA_HOME/bin/java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
[X@X hadooptest]$ hadoop version
Hadoop 0.20.2-cdh3u5
Subversion file:///data/1/tmp/topdir/BUILD/hadoop-0.20.2-cdh3u5 -r 30233064aaf5f2492bc687d61d72956876102109
Compiled by root on Fri Oct 5 18:45:42 PDT 2012
From source with checksum de1770d69aa93107a133657faa8ef467
[X@X hadooptest]$ javac -source 5.0 -classpath /usr/lib/hadoop-1.0.1/hadoop-core-1.0.1.jar -d wordcount_classes/ WordCount.java
----------
1. ERROR in WordCount.java (at line 0)
package org.myorg;
^
The type Iterator is not generic; it cannot be parameterized with arguments <V2>
----------
2. ERROR in WordCount.java (at line 29)
public void reduce(Text key, Iterator<IntWritable> values, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
^^^^^^^^
The type Iterator is not generic; it cannot be parameterized with arguments <IntWritable>
----------
2 problems (2 errors)[X@X hadooptest]$
我知道这个问题可能不是 Hadoop 特有的,但我主要不是 Java 用户。当我习惯使用 Hadoop 的本地语言时,我可能会选择切换到使用 C++ 库(但这是另一天的故事)。我用谷歌搜索了这个问题,我发现它通常表明使用 1.4.X JRE ......我们也有:
[fraha1@intel06 hadooptest]$ java -version
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-48)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[fraha1@intel06 hadooptest]$ $JAVA_HOME/bin/java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
我已将 ~/.bash_profile 设置为定向到 1.6 JRE,但大概 javac 配置为仍重定向到默认的 1.4。我怎样才能解决这个问题?