1.首先去 这里 http://download.java .net/openjdk/jdk7/ 下载 OpenJDK7的 源码 zip包 2. 安装编译工具包 如没安装aptitude,则先安装aptitude (sudo apt-get install aptitude) sudo aptitude build-dep openjdk-6 3. 注意 :Ubuntu系统的 语言 必须 切换 到 English ( 系统 设置 - > 语言 支持 ) 4.修改hotspot/make/linux下的Makefile文件,注释掉以下内容,若不注释,会报错,然后exit 1退出编译: check_os_version:
#ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),)
# $(QUIETLY) >&2 echo "*** This OS is not supported:" `uname -a`; exit 1;
#endif
5.修改jdk/make/javax/sound/jsoundalsa/下的Makefile文件,将 LDFLAGS += -lasound 改成 EXTRA_LIBS += -lasound 否则编译出错 6. 准备编译脚本:buildjdk.sh,放在解压对openjdk源码根目录下 #!/bin/bash
export LANG=C
export ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk
export ALLOW_DOWNLOADS=true
export USE_PRECOMPILED_HEADER=true
export SKIP_DEBUG_BUILD=false
export SKIP_FASTDEBUG_BUILD=true
export DEBUG_NAME=debug
unset CLASSPATH
unset JAVA_HOME
make sanity && make
7.执行编译脚本,./buildjdk.sh 8. 编译完成,检查结果 -- Build times ----------
Target debug_build
Start 2012-02-24 21:44:33
End 2012-02-24 22:40:32
00:00:52 corba
00:23:09 hotspot
00:09:25 jaxp
00:08:38 jaxws
00:13:01 jdk
00:00:54 langtools
00:55:59 TOTAL
-------------------------
make[1]: Leaving directory `/home/nathan/study/openjdk'
nathan@ubuntu:~/study/openjdk$ build/linux-i586-debug/j2sdk-image/bin/java -version
openjdk version "1.7.0-internal-debug"
OpenJDK Runtime Environment (build 1.7.0-internal-debug-nathan_2012_02_24_20_17-b00)
OpenJDK Server VM (build 21.0-b17-jvmg, mixed mode)
refrence:
1:http://www.85java.com/viewthread.php?tid=20878
2.http://stackoverflow.com/questions/9048254/how-to-compile-an-openjdk-7-debug-build-on-ubuntu-11-10