# Installation
# Windows
有两种方法提取 Oracle JDK。
EXE 文件运行提取:
- 执行安装程序,直到出现欢迎页面,不要点击下一步或关闭它。
- 打开
%USERPROFILE%\AppData\LocalLow\Oracle\Java,转到 JDK 文件夹。 - 有以下文件:
- jdk1.8.0_20264.msi: the MSI installer
- sj180202.cab: the JRE runnable
- ss180202.cab: the src.zip we are looking for
- st180202.cab: the tools.zip we can extract the JDK from
- sz180202.cab: the COPYRIGHT file
- 打开文件,并将 src.zip 和 tools.zip 复制到安全位置,因为关闭安装程序时 cab 文件将消失。
7-Zip 提取:
- 运行 7-Zip,提取 JDK 安装程序。
- 打开
.rsrc\1033有以下文件:- JAVA_CAB7: the JRE runnable
- JAVA_CAB9: the src.zip we are looking for
- JAVA_CAB10: the tools.zip we can extract the JDK from
- JAVA_CAB11: the COPYRIGHT file
- 运行以下命令,再次提取我们需要的内容
$ extrac32 JAVA_CAB7\108 $ extrac32 JAVA_CAB9\110 $ extrac32 JAVA_CAB10\111 $ extrac32 JAVA_CAB11\112
最后转换 tools.zip 格式,.pack to .jar:
$ for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar"
# Linux
# OpenJDK
$ yum install java-1.8.0-openjdk
# Oracle JDK
# vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_211
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
# 参考文献
- Huawei Cloud Mirror (opens new window)
- Checksum (opens new window)
- Amazon Corretto (opens new window)
- AdoptOpenJDK (opens new window)
- Zulu (opens new window)
- RedHat (opens new window)
- Microsoft (opens new window)
- Extract src.zip from JDK Installer (opens new window)
- Convert JDK from EXE to ZIP (opens new window)