1.安装编译所需依赖包
sudo apt-get install libx11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev
sudo apt-get install libcups2-dev
sudo apt-get install libfreetype6-dev
sudo apt-get install libasound2-dev
如果报错,更新Ubuntu源(更新过程要成功,如果报错,自行百度)
apt-get update
2.安装OpenJdk1.7
由于我们编译的是OpenJDK 8,所以,Bootstrap JDK最好采用OpenJDK 1.7版本的
直接运行如下命令:
sudo apt-get install openjdk-7-jre
sudo apt-get install openjdk-7-jdk
安装完成后,输入 java -version
java version "1.7.0_121"
OpenJDK Runtime Environment (IcedTea 2.6.8) (7u121-2.6.8-1ubuntu0.12.04.3)
OpenJDK 64-Bit Server VM (build 24.121-b00, mixed mode)
3.下载OpenJdk8源码包
地址:https://download.csdn.net/download/tiglle/10810465
将包上传至Ubuntu,解压
①进入OpenJdk8根目录:
cd /tiglle/openjdk/openjdk-8u40-src-b25-10_feb_2015/openjdk
②输入命令 bash configure
如果出现
configure: error: Could not find a C++ compiler. You might be able to fix this by running 'sudo apt-get install build-essential'
输入命令sudo apt-get install build-essential
如果出现
Build performance summary:
* Cores to use: 2
* Memory limit: 2627 MB
* ccache status: not installed (consider installing)
输入命令sudo apt-get install ccache
检查成功
Configuration summary:
* Debug level: release
* JDK variant: normal
* JVM variants: server
* OpenJDK target: OS: linux, CPU architecture: x86, address length: 64
Tools summary:
* Boot JDK: java version "1.7.0_121" OpenJDK Runtime Environment (IcedTea 2.6.8) (7u121-2.6.8-1ubuntu0.12.04.3) OpenJDK 64-Bit Server VM (build 24.121-b00, mixed mode) (at /usr/lib/jvm/java-7-openjdk-amd64)
* C Compiler: gcc-4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) version 4.6.3 (at /usr/bin/gcc-4.6)
* C++ Compiler: g++-4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) version 4.6.3 (at /usr/bin/g++-4.6)
Build performance summary:
* Cores to use: 2
* Memory limit: 2627 MB
* ccache status: installed and in use
WARNING: The result of this configuration has overridden an older
configuration. You *should* run 'make clean' to make sure you get a
proper build. Failure to do so might result in strange build problems.
③开始编译 sudo make
编译时间比较久。。。
----- Build times -------
Start 2018-11-27 14:30:44
End 2018-11-27 14:49:09
00:00:37 corba
00:13:12 hotspot
00:00:17 jaxp
00:00:26 jaxws
00:03:20 jdk
00:00:32 langtools
00:18:25 TOTAL
-------------------------
Finished building OpenJDK for target 'default'
编译成功