Prerequisites
-
Download Oracle jdk-6u45-linux-i586.bin from Oracle website. Openjdk is unsuitable here because some package like sun.net.dns.ResolverConfiguration only exists in rt.jar of Oracle jdk;
-
Install (./jdk.bin) this jdk at ~/apps/jdk with current user (do not install it into /opt with root user, because this will cause access restriction of rt.jar of jdk);
-
Add $JAVA_HOME and $CLASSPATH into /etc/profile and re-log into OS to validate;
-
Add this jdk to eclipse (Preferences -> Install JREs);
Method 8-10
Follow Working with Hadoop under Eclipse
- make sure your maven version is 3.x (mvn --version), if not:
sudo apt-get remove maven2 sudo apt-get update sudo apt-get install maven
-
git clone git://git.apache.org/hadoop-common.git ()
-
mvn install -DskipTests
-
mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true
Method 8-9
-
Create a Java Project in Eclipse, modify default output folder to $PROJECT_HOME/out (because "bin" is a script folder in hadoop source pack);
-
Exclude src from source folder and create "lib", "conf" folder under $PROJECT_HOME;
-
Import $HADOOP_HOME/src, lib, conf into $PROJECT_HOME;
-
Add all jar files under lib to build path;
-
Add ant.jar to build path;
-
Add mapred, tools, ant, core, hdfs under src folder as source folder;
Verify
-
modify config files;
-
run hadoop