一、設備

image.png
二、安裝
下載jdk1.6 https://support.apple.com/kb/DL1572?locale=zh_CN
操作
下載后直接安裝會提示“磁盤上已經(jīng)有了更高版本”,
解決方法
- 推出剛剛安裝的pkg
- 打開Mac 自帶的腳本編輯器,不是文本編輯器;輸入以下代碼
set theDMG to choose file with prompt "Please select javaforosx.dmg:" of type {"dmg"}
do shell script "hdiutil mount " & quoted form of POSIX path of theDMG
do shell script "pkgutil --expand /Volumes/Java\\ for\\ macOS\\ 2017-001/JavaForOSX.pkg ~/tmp"
do shell script "hdiutil unmount /Volumes/Java\\ for\\ macOS\\ 2017-001/"
do shell script "sed -i '' 's/return false/return true/g' ~/tmp/Distribution"
do shell script "pkgutil --flatten ~/tmp ~/Desktop/ModifiedJava6Install.pkg"
do shell script "rm -rf ~/tmp"

image.png
腳本執(zhí)行時會選擇dmg文件,選擇下載的jdk1.6的安裝包就行,當前是“JavaForOSX.dmg”;執(zhí)行完會在桌面生成一個新的安裝包ModifiedJava6Install.pkg,雙擊安裝就可以了
三、配置profile
vi ~/.bash_profile
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home"
export PATH="$PATH:$JAVA_HOME/bin"
刷新配置
source ~/.bash_profile

image.png