编译openjdk6

晚上试了下手工编译openjdk6。
http://download.java.net/openjdk/jdk6/下载源码解压到openjdk6。我编译用的OS是ubuntu11.04,参考源代码根目录下的README-builds.html中Ubuntu 9.04的说明,首先安装openjdk-6:
sudo apt-get install openjdk-6-jdk #编译openjdk6之前要先安装openjdk6???诡异。。。

设置环境:
export LANG=C 
export ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk #将ALT_BOOTDIR设置为刚安装好的openjdk6目录

还要注意unset JAVA_HOME这个环境变量
unset JAVA_HOME
unset LD_LIBRARY_PATH

接着是数次的编译出错,根据提示安装缺少的包:
sudo apt-get install gawk libasound2-dev libfreetype6-dev lesstif2-dev libcupsys2-dev libxtst-dev

开始编译:
make ALLOW_DOWNLOADS=true all #ALLOW_DOWNLOADS=true是因为需要从openjdk的网站下载jaxws的源代码,为什么不直接打包在openjdk的源代码中呢???

最后在CPU一片繁忙和风扇的声响中编译成功了

2011-06-25 更新:

仔细看了源码根目录下的README-builds.html,原来编译前事先要安装好的JDK被称为bootstrap jdk,文件中是这样描述的,但也没有具体说编译哪些文件需要JDK6,我估计是langtools包里面javac之类的工具吧。
All OpenJDK builds require access to the previously released JDK 6, this is often called a bootstrap JDK.

Normally the "boot" JDK is the previously released version of the JDK, so it's unusual for a JDK 6 build like this to require a JDK 6 "boot". Unfortunately, it is currently required due to some JDK 6 dependencies in some of the sources. 


另外编译的时候还需要安装好ant。如果只需要hotspot以及JDK核心类的话,可以跳过jaxws和jaxp等与XML和web service相关的API。如果想加快编译速度,还可以设置HOTSPOT_BUILD_JOBS,增加并行的任务数,设置成CPU核数相等就差不多了。
make BUILD_CORBA=false BUILD_JAXP=false BUILD_JAXWS=false HOTSPOT_BUILD_JOBS=4

最新的结果是。。。居然编译出错了。。。暂时还不知道原因,先放一放吧



你可能感兴趣的:(java,jvm,jdk,ubuntu,OS)