Mac jdk1.8环境下安装jdk1.6

一、设备

image.png

二、安装

下载jdk1.6 https://support.apple.com/kb/DL1572?locale=zh_CN

操作

下载后直接安装会提示“磁盘上已经有了更高版本”,

解决方法
  1. 推出刚刚安装的pkg
  2. 打开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

脚本执行时会选择dmg文件,选择下载的jdk1.6的安装包就行,当前是“JavaForOSX.dmg”;执行完会在桌面生成一个新的安装包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

你可能感兴趣的:(Mac jdk1.8环境下安装jdk1.6)