原文地址:http://blog.csdn.net/jiyiqinlovexx/article/details/41179293

为了深入学习ZooKeeper源码,首先就想到将其导入到Eclispe中,所以要先将其编译为Eclispe工程。

 

1、什么是Ant???

Apache Ant™

Apache Ant is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications. Ant supplies a number of built-in tasks allowing to compile, assemble, test and run Java applications. Ant can also be used effectively to build non Java applications, for instance C or C++ applications. More generally, Ant can be used to pilot any type of process which can be described in terms of targets and tasks.

Ant is written in Java. Users of Ant can develop their own "antlibs" containing Ant tasks and types, and are offered a large number of ready-made commercial or open-source "antlibs".

Ant is extremely flexible and does not impose coding conventions or directory layouts to the Java projects which adopt it as a build tool.

Software development projects looking for a solution combining build tool and dependency management can use Ant in combination with Apache Ivy.

The Apache Ant project is part of the Apache Software Foundation.

Apache Ant,是一个将软件编译、测试、部署等步骤联系在一起加以自动化的一个工具,大多用于Java环境中的软件开发。由Apache软件基金会所提供。
用过Linux系统的人都应该知道 make这个命令。当编译Linux内核及一些软件的源程序时,经常要用这个命令。Make命令其实就 是一个项目管理工具,而Ant所实现功能与此类似。像make,gnumake和nmake这些编译工具都有 一定的缺陷,但是Ant却克服了这些工具的缺陷。最初Ant开发者在开发跨平台的应用时,同样也 是基于这些缺陷对Ant做了更好的设计。

Ant的核心是其构建文件,当开始一个新的项目时,首先应该编写Ant构建文件。构建文件定义了构建过程,并被团队开发 中每个人使用。Ant构建文件默认名为build.xml,也可以取其他的名字。只不过在运行的时候 把这个命名当作参数传给Ant。构建文件可以放在任何的位置。一般做法是放在项目顶层目录中。 这样可以保持项目的简洁和清晰。下面是一个典型的项目层次结构。
(1) src存放文件。
(2) class存放编译后的文件。
(3) lib存放第三方JAR包。
(4) dist存放打包,发布以后的代码。

更多关于ant的知识大家可以自行搜索。

2、安装ant

(1)下载ant,我下载的是apache-ant-1.9.4-bin.zip(地址:http://ant.apache.org/bindownload.cgi

(2)解压到特定目录,设置ANT_HOME(ant的解压路径)和path(%ANT_HOME%\bin)

(3)打开cmd,运行ant -version,出现版本信息说明安装成功了。

3、下载Zookeeper源码并用ant进行编译为eclipse工程

Zookeeper GitHub的下载地址是:https://github.com/apache/zookeeper

解压,打开cmd,切换到Zookeeper源码的根目录下面(下面有一个build.xml文件),然后输入命令> ant eclipse

出现下面界面提示编译成功:

然后打开eclispe,随便什么版本,选择import,类型是现有的eclispe工程。

点击完成,但是发现我的源码竟然有好几处错误,不过类型都是一样,都是Cannot switch on a value of type XXX:

在网上查了一下,跟工程文件使用来编译的JDK版本有关,需要将jdk 7切换到jdk 6:

在导入的Zookeeper工程上面点击右键-》properties-》Java Compiler,将compiler compliance level切换为1.6:

这样错误就消失了,下面就可以开始进入真正的Zookeeper源码之旅了!

Zookeeper源码编译为Eclipse工程(转)的更多相关文章

  1. Zookeeper源码编译为Eclipse工程(win7下Ant编译)

    前言 ZooKeeper是雅虎的.用Ant进行软件构建. 千里之行,始于足下.想看源码的第一步,是下载源码并导入某个IDE工具. Ant http://ant.apache.org/ Windows: ...

  2. (转)把hadoop源码关联到eclipse工程

    把hadoop源码关联到eclipse工程     转:http://www.superwu.cn/2013/08/04/355 在eclipse中阅读源码非常方便,利于我们平时的学习,下面讲述如何把 ...

  3. Hadoop,HBase,Zookeeper源码编译并导入eclipse

    基本理念:尽可能的参考官方英文文档 Hadoop:  http://wiki.apache.org/hadoop/FrontPage HBase:  http://hbase.apache.org/b ...

  4. Apache Flume 1.7.0 源码编译 导入Eclipse

    前言 最近看了看Apache Flume,在虚拟机里跑了一下flume + kafka + storm + mysql架构的demo,功能很简单,主要是用flume收集数据源(http上报信息),放入 ...

  5. zookeeper 源码编译

    环境:mac 1.github上下载 源码 项目地址:https://github.com/apache/zookeeper 2.安装 ant mac:brew update ->  brew ...

  6. 使用Maven将Hadoop2.2.0源码编译成Eclipse项目

    编译环境: OS:RHEL 6.3 x64 Maven:3.2.1 Eclipse:Juno SR2 Linux x64 libprotoc:2.5.0 JDK:1.7.0_51 x64 步骤: 1. ...

  7. 将android Settings 源码 导入到 eclipse工程

    1.  新建 android 项目 拷贝源码/packages/apps/Settings到你的其它目录. 在eclipse中,新建项目,但是要从exitting source选择: 2. 导入相关的 ...

  8. hadoop源码import到eclipse工程

    1.解压hadoop-1.1.2.tar.gz,重点在src文件夹 2.在eclipse中通过菜单栏创建一个java工程,工程名随便 3.在创建的工程上,点击右键,在弹出菜单中选择最后一项,在弹出窗口 ...

  9. 【转】如何把hadoop-1.x源码关联到Eclipse工程

    [转]http://www.tuicool.com/articles/mIb2EzU

随机推荐

  1. Oracle求连续的年份

    SELECT ('2013') + ROWNUM year FROM dualCONNECT BY ROWNUM <= 2;

  2. CentOS7 基础配置

    Centos 7 部分>>>>>>>>>>>>>>>>>>>>>>& ...

  3. java使用split切割字符串的时候,注意转义字符

    今天在做项目的时候发现一个奇怪的问题 File file = new File("d:\\a.txt"); BufferedReader br = new BufferedRead ...

  4. iOS - Mac OS X 终端设置

    Mac OS X 终端设置 1)Finder 中显示资源库 方法一: 在 "终端" 中输入下面的命令: 显示: chflags nohidden ~/Library/ 隐藏: ch ...

  5. struts(二) ---中参数传值

    struts中参数传值的方式有 种: 第一种:直接通过属性来传值 第二种: 第三种:

  6. How to change owner of PostgreSql database?

    ALTER DATABASE name OWNER TO new_owner;

  7. BitMap存储jpg到手机sd卡中

    /** * 将BitMap转成Jpeg图片保存到sdcard(便于以后debug调试查看和裁切调试) */ private void saveBitmap(Bitmap bitmap, String ...

  8. laravel 的.env 配置文件

      (相关的环境变量) APP_ENV=localAPP_DEBUG=trueAPP_KEY=base64:cWMz1hM4dp9ihoOtUs6iV+BDZX9KtjYvMALFmyEPQfI= D ...

  9. 51nod 1445 变色DNA(dij)

    题目链接:51nod 1445 变色DNA 看了相关讨论再去用最短路:val[i][j]之间如果是'Y',说明i可以到达j,并且i到达j的代价是i那行 1到j-1 里面'Y'的数量. 最后,求 0到n ...

  10. WebView注入Java对象注意事项

    在android4.2以前,注入步骤如下: webview.getSetting().setJavaScriptEnable(true); class JsObject { public String ...