MacOS – Java uninstalled but still cannot install java 6 macOS

javamacos

I'm trying to install Java SE 6 because I need it to use Scilab, I follow this and this tutorials for uninstall java, but still cannot install Java SE 6.

When I'm trying to install appears this message You cannot install Java for macOS 2017-001 on this disk. A newer version of this package is already installed.

The command java -version in terminal shows No Java runtime present, requesting install.

Best Answer

  • First, try to download listed Java and if that didn't go straightway, use the following script to install it.

Here is a simpler way, an AppleScript that removes the installation limits from Java for macOS 2017-001.

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/Java.pkg"
do shell script "rm -rf ~/tmp"
display dialog "Modified Java.pkg saved on desktop" buttons {"Ok"}

The script asks you to select the dmg file, opens the file, unpacks JavaForOSX.pkg, modifies the Distribution file and saves a new pkg file on Desktop, Java.pkg, that can be installed on Catalina.


For those who prefer doing this directly in Terminal:

t=${TMPDIR:-/tmp}/java
hdiutil mount /path/to/javaforosx.dmg
pkgutil --expand /Volumes/Java\ for\ macOS\ 2017-001/JavaForOSX.pkg "$t"
hdiutil unmount /Volumes/Java\ for\ macOS\ 2017-001
sed -i '' 's/return false/return true/g' "$t"/Distribution
pkgutil --flatten "$t" ~/Desktop/Java.pkg
rm -rf "$t"
open ~/Desktop/Java.pkg