hadoop0.20.2 compilation in Eclipse

Source: Internet
Author: User
Tags manual svn

1. Download the Hadoop source code
Hadoop member source code download address: Http://svn.apache.org/repos/asf/hadoop, please use SVN download, in the SvN browser will be in the trunk directory under the source check-out out. Please note that only check-out the contents of the tag directory on SVN, such as:
http://svn.apache.org/repos/asf/hadoop/common/tag/release-0.20.2,


2. Preparing the compilation Environment

2.1. System

CentOS5.5

2.2. Hadoop code version
Hadoop-0.20.2-release

2.3. Networking
Compiling Hadoop relies on many third-party libraries, but the build tool ant automatically downloads the missing libraries from the Web, so you must ensure that your machine has access to the Internet.
2.4. java
Compile Hadoop to use JDK1.6, URL: http://java.sun.com/javase/downloads/index.jsp.
After installation, set the JAVA_HOME environment variable.
2.5. Ant
Need to use ant tools to compile Hadoop, you can download ant from: http://ant.apache.org/ivy/download.cgi

After installation, set the ANT_HOME environment variable.

2.6. Eclipse

Eclipse can be downloaded from the http://www.eclipse.org/downloads/.

3. Compiling Hadoop

3.1. Compiling Hadoop
Step 1) Right-click in the package view of Elipse and select New->java Project, as shown in the following illustration:

Step 2) Select the source code directory and set the project name.

In the dialog box shown above, click the Browse button, select the hadoop-0.20.2 source directory, and set ProjectName to Hadoop-0.20.2-dev. Once the project has been imported, you can see that hadoop-0.20.2 has been imported, but you can see the Red Fork in the directory because Elipse uses Java builder instead of Ant Builder, So the next step is to set up using ant Builder.


Step 3) Set Builder to ant: Right-click hadoop-0.20.2-dev>properties->builders:

In the interface shown above, click on the New button to select Ant Builder in the popup dialog box and the following dialog will pop up:

Click the Browse for File System button, select the Build.xml file under the hadoop-0.20.2 source directory, and set name to Ant_builder (name can be changed to other, but Ant_builder is recommended, As this is true), the operation results are as follows:

In addition to the settings shown in the figure above, it is also necessary to set the targets as shown in the figure below, and it is recommended to set the manual build method instead of the auto build compilation. Because in auto build mode, any changes will trigger the compilation, while manual build mode, only when needed, click the Compile button or menu compilation.

Each Hadoop member needs to be compiled into a jar, so make a change as shown in the following figure:

When you are sure, return to the Edit Configuration dialog box as shown in the following illustration:

When you are done, go back to the Builder Main dialog box, and then move the Java Builder down in the dialog box and remove the previous tick.
Enter Eclipse main interface, because previously selected manual Build, so need manual way to drive compile, compile successful, can see buildsuccessful words.

Note: If the buildautomatically in the menu shown in the image above is checked, the Build submenu may not appear in the common's right-click menu.
During the compilation process, Ant automatically downloads the libraries it relies on from the web. After the hadoop-0.20.2 compilation is completed successfully, you can find the compiled file Hadoop-core-0.20.2-dev.jar in the build directory.

3.2 Error occurred during compilation


1. The eclipse plugin provided by Hadoop may sometimes be problematic because of the eclipse version or the OS version.
Workaround:
1) Modify $hadoop_home/src/contrib/build-contrib.xml
Add one line: <propertyname= "Eclipse.home" location= "/home/gushui/eclipse"/>
The/home/gushui/eclipse in the back of the sentence is replaced by his own $eclipse_home.

2) Modify $hadoop_home/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/launch/ Hadoopapplicationlaunchshortcut.java
Comment out the original//importorg.eclipse.jdt.internal.debug.ui.launcher.javaapplicationlaunchshortcut;
Changed to Importorg.eclipse.jdt.debug.ui.launchConfigurations.JavaApplicationLaunchShortcut;

2. Error:

Buildfailed

Cannot write to the specified tarfile!

Workaround:

Build.xml in the Hadoop-0.20.2-dev directory
<!--
<tar compression= "gzip" destfile= "${build.classes}/bin.tgz" >
<tarfileset dir= "bin" mode= "755"/>
</tar>
-

Log off and run successfully.

Reference http://blog.csdn.net/basicthinker/article/details/6174442

Reference: http://hi.baidu.com/xxjjyy2008/blog/item/7b5ed10f20e6a9346059f335.html
Reference: http://hadoop.hadoopor.com/thread-941-1-1.html

http://trac.nchc.org.tw/cloud/wiki/waue/2010/0211



Transfer from http://www.cnblogs.com/zyumeng/archive/2013/03/22/2975165.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.