sudo apt-get install mercurial
hg fclone http://hg.openjdk.java.net/jdk7/jdk7
# wget http://www.java.net/download/openjdk/jdk7/promoted/b147/openjdk-7-fcs-src-b147-27_jun_2011.zip
# unzip openjdk-7-fcs-src-b147-27_jun_2011.zip
sudo apt-get install build-essential
sudo apt-get install ant
sudo apt-get install libxrender-dev sudo apt-get install xorg-dev
sudo apt-get install libasound2-dev
sudo apt-get install libcups2-dev
sudo apt-get install openjdk-6-jdk
或者下载oracle的jdk也可以
sudo apt-get install gawk zip libxtst-dev libxi-dev libxt-dev
!/bin/bash # cd jdk source code folder cd ~/openjdk7 # export ALT_BOOTDIR export LANG=C ALT_BOOTDIR=/home/lichengwu/openjdk_build_files/jdk1.6.0_32 # set build profile jdk/make/jdk_generic_profile.sh # disable JAVA_HOME export -n JAVA_HOME # export ALT_JDK_IMPORT_PATH export ALT_JDK_IMPORT_PATH=/home/lichengwu/openjdk_build_files/jdk1.6.0_32 # start build make DEBUG_NAME=all_fastdebug BUILD_JAXWS=false BUILD_JAXP=false
如果你通过上面步骤就编译成功了,那你真的人品爆发了,以下是我编译时候遇到的问题
vim hotspot/make/linux/makefiles/gcc.make
lichengwu@s4:~/bin$ uname -r #查看当前的内核版本: 3.2.0-20-generic 修改文件/home/thebye85/jdk7/hotspot/make/linux/Makefile #在这行最后加上当前的内核版本3.2%,如下: lichengwu@s4:~/bin$ SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 2.7% 3.2%
方法二:
vi hotspot/make/linux/Makefile
注释掉下面代码:
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
cd jdk/make/javax/sound/jsoundalsa vim Makefile
#找到CPPFLAGS ,在其结尾,添加 -lasound
ln -s build/linux-amd64/lib/amd64/libjsound.so
build/linux-amd64/lib/amd64/libjsoundalsa.so
如果ln不行 就用cp
corba hotspot langtools 编译时间很短是因为编译在hotspot时候出错,重新编译,如果正常一次跑通,大概半个小时 我用的是虚拟机:
########################################################################
##### Leaving jdk for target(s) sanity all images #####
########################################################################
##### Build time 00:09:14 jdk for target(s) sanity all images #####
########################################################################
-- Build times ----------
Target all_fastdebug_build
Start 2012-06-13 13:53:38
End 2012-06-13 14:03:13
00:00:07 corba
00:00:08 hotspot
00:09:14 jdk
00:00:06 langtools
00:09:35 TOTAL
查看版本
lichengwu@s4:~/openjdk7/build/linux-amd64/j2sdk-image/bin$ java -version
java version "1.6.0_24"
OpenJDK Runtime
Environment (IcedTea6 1.11.1) (6b24-1.11.1-4ubuntu3)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
lichengwu@s4:~/openjdk7/build/linux-amd64/j2sdk-image/bin$ ./java -version
openjdk version "1.7.0-internal-all_fastdebug"
OpenJDK Runtime
Environment (build 1.7.0-internal-all_fastdebug-lichengwu_2012_06_13_11_47-b00)
OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)
编译:http://hg.openjdk.java.net/jdk7/build/raw-file/tip/README-builds.html
http://thebye85.iteye.com/blog/1545311
关于为啥要自己编译jdk:http://rednaxelafx.iteye.com/blog/1549577