编译环境:
Eclipse Juno(4.2)
JDK1.6.0_25
hadoop-0.20.2-cdh3u5
编译步骤:
1.在eclipse导入hadoop-0.20.2-cdh3u5.tar.gz解压目录下的src\contrib\eclipse-plugin项目
此时项目会报找不到lib/hadoop-core.jar,在项目根目录下建立lib文件夹,在hadoop-0.20.2-cdh3u5解压目录下复制hadoop-core-0.20.2-cdh3u5.jar文件到lib文件夹下
2.复制hadoop-0.20.2-cdh3u5解压目录下src\contrib\build-contrib.xml文件到项目根目录下
修改<property name="hadoop.root" location="${src.contrib.dir}/../../"/>项为hadoop-0.20.2-cdh3u5解压目录
<property name="hadoop.root" location="E:/hadoop/hadoop-cdh3u5/hadoop-0.20.2-cdh3u5"/>
添加<property name="eclipse.home" location="D:/work_java/eclipse"/>项,值为eclipse安装目录
添加<property name="version" value="0.20.2-cdh3u5"/>项,值为hadoop的版本
3.修改<import file="../build-contrib.xml" />项为当前目录<import file="./build-contrib.xml" />
加入<path id="hadoop-jars">
<fileset dir="${hadoop.root}/">
<include name="hadoop-*.jar" />
</fileset>
</path>
修改<path id="classpath">
<pathelement location="${build.classes}" />
<pathelement location="${hadoop.root}/build/classes" />
<path refid="eclipse-sdk-jars" />
<path refid="hadoop-jars" />
</path>
4.在hadoop-0.20.2-cdh3u5解压目录下建立build文件夹,复制hadoop-core-0.20.2-cdh3u5.jar到build文件夹下
在build文件夹下建立ivy\lib\Hadoop\common文件夹,复制lib/commons-cli-1.2.jar到此路径下
5.Run As -> Ant Build build.xml文件,在解压目录下生成build\contrib\eclipse-plugin\hadoop-eclipse-plugin-0.20.2-cdh3u5.jar
6.把log4j-1.2.15.jar,jackson-core-asl-1.5.2.jar,jackson-mapper-asl-1.5.2.jar,guava-r09-jarjar.jar中的org复制到hadoop-eclipse-plugin-0.20.2-cdh3u5.jar中
复制hadoop-eclipse-plugin-0.20.2-cdh3u5.jar到eclipse安装目录\plugins下