需要下载以下安装文件:
jdk-6u30-windows-i586.exe
apache-ant-1.9.1-bin.zip
eclipse-jee-indigo-SR2-win32.zip
hadoop-1.0.4.tar.gz
1、安装jdk配置JAVA_HOME,并将%JAVA_HOME%\bin添加到Path变量
2、解压apache-ant-1.9.1-bin.zip至某一目录(C:\Hadoop Plugin),配置ANT_HOME,并将%ANT_HOME%\bin添加到Path变量
3、将hadoop-1.0.4.tar.gz解压到同一目录下(C:\Hadoop Plugin)
4、将eclipse-jee-indigo-SR2-win32.zip解压到C:\Hadoop Plugin/目录下,更名为eclipse
5、修改${HADOOP_HOME}/src/contrib/目录下的build-contrib.xml文件添加如下两行,分别添加Eclipse安装路径和Hadoop版本
<project name="hadoopbuildcontrib" xmlns:ivy="antlib:org.apache.ivy.ant"> <property name="eclipse.home"location="C:\eclipse"/> --添加部分 <property name="version" value="1.0.4"/> --添加部分 <property name="name" value="${ant.project.name}"/> <property name="root" value="${basedir}"/> <property name="hadoop.root" location="${root}/../../../"/>
<path id="eclipse-sdk-jars"> <fileset dir="${eclipse.home}/plugins/"> <include name="org.eclipse.ui*.jar"/> <include name="org.eclipse.jdt*.jar"/> <include name="org.eclipse.core*.jar"/> <include name="org.eclipse.equinox*.jar"/> <include name="org.eclipse.debug*.jar"/> <include name="org.eclipse.osgi*.jar"/> <include name="org.eclipse.swt*.jar"/> <include name="org.eclipse.jface*.jar"/> <include name="org.eclipse.team.cvs.ssh2*.jar"/> <include name="com.jcraft.jsch*.jar"/> </fileset> <fileset dir="../../../"> --添加部分 <include name="hadoop*.jar"/> --添加部分 </fileset> --添加部分 </path>
>copy %Hadoop_HOME%\lib\commons-cli-1.2.jar %HADOOP_HOME%\build\ivy\lib\Hadoop\common\ >copy %Hadoop_HOME%\hadoop-core-1.0.4.jar %Hadoop_HOME%\build\
8、打开命令行cmd,切换到 C:\Hadoop Plugin\hadoop-1.0.4\src\contrib\eclipse-plugin目录,运行ant jar
C:\Hadoop Plugin\hadoop-1.0.4\src\contrib\eclipse-plugin>ant jar Buildfile: C:\Hadoop Plugin\hadoop-1.0.4\src\contrib\eclipse-plugin\build.xml check-contrib: [echo] eclipse.home unset: skipping eclipse plugin init: ivy-download: [get] Getting: http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.1.0/ivy-2.1.0.jar [get] To: C:\Hadoop Plugin\hadoop-1.0.4\ivy\ivy-2.1.0.jar [get] Not modified - so not downloaded ivy-probe-antlib: ivy-init-antlib: ivy-init: [ivy:configure] :: Ivy 2.1.0 - 20090925235825 :: http://ant.apache.org/ivy/ :: [ivy:configure] :: loading settings :: file = C:\Hadoop Plugin\hadoop-1.0.4\ivy\ivysettings.xml ivy-resolve-common: [ivy:resolve] :: resolving dependencies :: org.apache.hadoop#eclipse-plugin;working@L-SHC-00436132 [ivy:resolve] confs: [common] [ivy:resolve] found commons-logging#commons-logging;1.0.4 in maven2 [ivy:resolve] found log4j#log4j;1.2.15 in maven2 [ivy:resolve] downloading http://repo1.maven.org/maven2/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar ... [ivy:resolve] ........... (37kB) [ivy:resolve] .. (0kB) [ivy:resolve] [SUCCESSFUL ] commons-logging#commons-logging;1.0.4!commons-logging.jar (1471ms) [ivy:resolve] downloading http://repo1.maven.org/maven2/log4j/log4j/1.2.15/log4j-1.2.15.jar ... [ivy:resolve] ........................................................... (382kB) [ivy:resolve] .. (0kB) [ivy:resolve] [SUCCESSFUL ] log4j#log4j;1.2.15!log4j.jar (2432ms) [ivy:resolve] :: resolution report :: resolve 4369ms :: artifacts dl 3911ms --------------------------------------------------------------------- | | modules || artifacts | | conf | number| search|dwnlded|evicted|| number|dwnlded| --------------------------------------------------------------------- | common | 2 | 2 | 2 | 0 || 2 | 2 | --------------------------------------------------------------------- ivy-retrieve-common: [ivy:retrieve] :: retrieving :: org.apache.hadoop#eclipse-plugin [sync] [ivy:retrieve] confs: [common] [ivy:retrieve] 2 artifacts copied, 0 already retrieved (419kB/27ms) [ivy:cachepath] DEPRECATED: 'ivy.conf.file' is deprecated, use 'ivy.settings.file' instead [ivy:cachepath] :: loading settings :: file = C:\Hadoop Plugin\hadoop-1.0.4\ivy\ivysettings.xml compile: jar: BUILD SUCCESSFUL Total time: 10 seconds
9、将所需jar包拷贝至编译生成的hadoop-eclipse-plugin-1.0.4.jar中
10、修改META-INF目录下的MANIFEST.MF,META-INF目录下的MANIFEST.MF,将classpath修改为:
Bundle-ClassPath:classes/,lib/hadoop-core.jar,lib/commons-cli-1.2.jar,lib/commonshttpclient-
3.0.1.jar,lib/jackson-core-asl-1.8.8.jar,lib/jackson-mapper-asl-1.8.8.jar,lib/commonsconfiguration-
1.6.jar,lib/commons-lang-2.4.jar
将该hadoop-eclipse-plugin-1.0.4.jar拷贝到eclipse plugs-in目录中,重新启动eclipse,至此,搭建完成hadoop eclipse编译环境。