1.首先去 这里 下载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.sh8. 编译完成,检查结果
-- 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)