Contents1Compile OpenJDK8 on MacOSX刨根问底探索分析Contents纯手工编译。在上尝试了一下,因为编译这玩意需要,而现在都升级到了,虽然可以下载旧版的,但试了一下貌似不太兼容。于是在中装来编译一下玩玩。在使用网络做端口转发的时候,竟然发现不支持主机的端口(貌似是权限的问题),改为则。sudo apt-get install mercurialsudo apt-get install lrzszhg clone http://hg.openjdk.java.net/jdk8u/jdk8ucd jdk8ush get_source.sh可能遇到的问题:...jdk: abort: stream ended unexpectedly (got 8159 bytes, expected 29096)...WARNING: hotspot exited abnormally (255)WARNING: jdk exited abnormally (255)WARNING: nashorn exited abnormally (255)解决办法是重试次就可以了。切换到最新的:hg tagshg up jdk8u162-b12安装依赖项:sudo apt-get install build-essentialsudo apt-get install libasound2-dev libcups2-dev libfreetype6-devsudo apt-get install libx11-dev libxext-dev libxrender-dev libxtst-dev libxt-devsudo apt-get updatesudo apt-get upgradesudo add-apt-repository ppa:openjdk-r/ppa sudo apt-get update sudo apt-get install openjdk-7-jdk # refer https://github.com/hgomez/obuildfactory/wiki/How-to-build-and-package-OpenJDK-8-on-Linux然后开始编译吧:bash ./configure --with-target-bits=64 --with-freetype-include=/usr/include/freetype2/ --with-freetype-lib=/usr/lib/x86_64-linux-gnu Contents2下面必须指定的路径,按照里面所说,期望的路径是Expecting the freetype libraries under lib/ and the headers under include/.而且特别指出*The build is now a "configure && make" style build*Any GNU make 3.81 or newer should work*The build should scale, i.e. more processors should cause the build to be done in less wall-clock time*Nested or recursive make invocations have been significantly reduced, as has the total fork/exec or spawning of sub processes during the build*Windows MKS usage is no longer supported*Windows Visual Studio vsvars*.bat and vcvars*.bat files are run automatically*Ant is no longer used when building the OpenJDK*Use of ALT_* environment variables for configuring the build is no longer supported因此有些文章上面设置等步骤不适用编译为了提高编译速度,在虚拟机中设置了使用个核心。我们需要指定编译使用的数来提高编译速度。make cleanrm -rf buildbash ./configure --with-target-bits=64 --with-freetype-include=/usr/include/freetype2/ --with-freetype-lib=/usr/lib/x86_64-linux-gnu --with-jobs=4这样配置完后的输出如下A new configuration has been successfully created in/home/riguz/jdk/jdk8u/build/linux-x86_64-normal-server-releaseusing configure arguments '--with-target-bits=64 --with-freetype-include=/usr/include/freetype2/ --with-freetype-lib=/usr/lib/x86_64-linux-gnu --with-jobs=4'.Configuration summary:* Debug level: release* JDK variant: normal* JVM variants: server* OpenJDK target: OS: linux, CPU architecture: x86, address length: 64Tools summary:* Boot JDK: java version "1.7.0_95" OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-3) OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode) (at /usr/lib/jvm/java-7-openjdk-amd64)* C Compiler: gcc-5 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 version 5.4.0 (at /usr/bin/gcc-5)* C++ Compiler: g++-5 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 version 5.4.0 (at /usr/bin/g++-5)Build performance summary:* Cores to use: 4 Contents3* Memory limit: 1997 MB* ccache status: not installed (consider installing)这里有个的提示,就是。但是这玩意安装之后貌似识别错误,索性不要了。然后就可以开始编译了make images尴尬的是虚拟机磁盘空间不够,幸亏可以动态调整一下VBoxManage modifyhd ~/VirtualBox\ VMs/lubuntu/lubuntu.vdi --resize 20480# 完了之后需要进入到系统,用分区工具调整分区大小,可能需要删除swap分区,扩展/后再重建swap分区sudo apt-get install gpartedgparted目标会create complete j2sdk and j2re images,花费了大约分钟时间----- Build times -------Start 2018-04-11 10:03:36End 2018-04-11 10:13:4700:00:23 corba00:00:15 demos00:04:49 hotspot00:01:02 images00:00:15 jaxp00:00:20 jaxws00:02:26 jdk00:00:28 langtools00:00:13 nashorn00:10:11 TOTAL-------------------------生成的文件在中riguz@riguz-VirtualBox:~/jdk/jdk8u/build/linux-x86_64-normal-server-release/images/j2sdk-image$ cd bin/riguz@riguz-VirtualBox:~/jdk/jdk8u/build/linux-x86_64-normal-server-release/images/j2sdk-image/bin$ lsappletviewer javadoc jdeps jsadebugd pack200 servertoolextcheck javah jhat jstack policytool tnameservidlj javap jinfo jstat rmic unpack200jar java-rmi.cgi jjs jstatd rmid wsgenjarsigner jcmd jmap keytool rmiregistry wsimportjava jconsole jps native2ascii schemagen xjcjavac jdb jrunscript orbd serialverriguz@riguz-VirtualBox:~/jdk/jdk8u/build/linux-x86_64-normal-server-release/images/j2sdk-image/bin$ ./java -versionopenjdk version "1.8.0-internal"OpenJDK Runtime Environment (build 1.8.0-internal- Contents4riguz_2018_04_11_10_03-b00)OpenJDK 64-Bit Server VM (build 25.71-b00, mixed mode)最后就是测试了。测试需要安装,注意一定要指定sudo apt-get install jtregcd test && make PRODUCT_HOME=`pwd`/../build/*/images/j2sdk-image JT_HOME=/usr/bin/jtreg all