zookeeper需要使用ant进行编译,eclipse中已经集成了ant,编译起来比较方便。需要找到zookeeper项目中的build.xml文件,右键点击,选择Run As->Ant Build
编译过程中,可能提示如下错误:
BUILD FAILED
D:\zookeeper-3.4.5\build.xml:240: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "D:\eclipse\jre"
解决的方法如下:
进入
Window > Preferences > Ant > Runtime > Classpath > Global Entries
点击Add External Jars,进入jdk的安装目录,选择lib/tools.jar。
之后重新编译,问题解决