OpenJDK8Windows编译
前⾔
Open JDK 是开源的JDK。通过对开源JDK的编译调试,我们可以深⼊了解JVM的运⾏原理。
以下是我的环境信息:
操作系统: Microsoft Windows 7 Professional x64 SP1
安装组件:
jdk最新下载安装步骤
1、Windows Unix Toolkit>  CYGWIN x64,放在E:\hub\cygwin64⽬录下
2、C/C++ Compiler  > Visual Studio 2010 Professional (x86) - DVD (English),包括WindowsSDK 7.1 X64
3、Bootstrap JDK > Oracle jdk1.7.0_80 x64,放在E:\sdkUnity\java\jdk1.7.0_80⽬录下
4、freetype ,使⽤ Visual Studio 2010 编译 x64 的freetype.dll⽂件,放在E:\hub\freetype⽬录下
⼀、准备编译环境
1、安装CYGWIN
下载完后,开始安装
安装过程选择镜像:
接下来是定制需要安装的⼯具,在默认的基础上,我们加装如下⼯具:
Binary Name  Category        Package        Description
================================================================
<        Devel            binutils      The GNU assembler, linker and binary utilities
<      Devel            make          The GNU version of the 'make' utility built for CYGWIN
<        Interpreters    m4            GNU implementation of the traditional Unix macro processor
<      Utils            cpio          A program to manage archives of files
<      Archive          zip          Package and compress (archive) files
<    Archive          unzip        Extract compressed files in a ZIP archive
<      System          procps        Display amount of free and used memory in the system
================================================================
(注: 此表来⾃OpenJDK8u的源代码根⽬录中的README-builds.html)
在输⼊框中建议Binary Name不带 exe搜索,按照建议的Category,对照Description选择正确的组件。如果没有,按Package搜索。以下是当前CYGWIN最新版本的搜索:
安装完,我们有⼀个图标在桌⾯:
2、安装VS2010
Visual Studio 2010 Professional (x86) - DVD (English)
ed2k://|file|en_visual_studio_2010_professional_x86_dvd_509727.iso|2351316992|D395B6381AC129209EE80D9BED4BA
主要需要C++ x64位编译器模块,如下图:
然后安装
WindowsSDK 7.1 X64(GRMSDKX_EN_DVD.iso)
A problem occurred while installing selected Windows SDK components.
Installation of the "Microsoft Windows SDK for Windows 7" product has reported the following error: Please refer to Samples\Setup\HTML\ConfigDetails.htm document for further information.
Click the View Log button to review the installation log.
To exit, click Finish.
解决办法:  卸载Visual C++ 2010 Redistributable
3、安装JDK7
在Oracle官⽹下载JDK7安装即可。
4、下载并安装(编译)feetype
由于OpenJDK中的swing与JConsole需要使⽤freetype的字体渲染功能,因此需要⾸先对其进⾏编译。
我们可以下载已经编译好的lib和dll直接使⽤,⽽不需要⾃⼰编译:
下载完后解压为E:\hub\freetype⽬录,把win64⽬录改为名称lib,如下所⽰:
⼆、获取OpenJDK源码
OpenJDK的源码有两种下载⽅式:
Source
Repository
采⽤Mercurial进⾏版本管理下载 ,为了获取最新版本的源码,我们需要下载TortoiseHg。
安装完注意配置TortoiseHg的hg.exe所在⽬录环境变量到PATH。
在⼀个⽬录(建议为英⽂路径)中右键选择 TortoiseHg&,克隆OpenJDK源码:
点击“克隆”,等待完成。
源码下载完成后,我们可以看到OpenJDK的⼯作台⽇志了。
源码中有⼀个README-builds.html 是构建OpenJDK的详细参考⽂档。本编的教程基本都会参考其中内容。