LoginSignup
5
5

More than 5 years have passed since last update.

OS X 10.10 YosemiteでJava7をインストールする方法

Last updated at Posted at 2014-09-24

アジェンダ

Oracleやbrew-caskから落としたpkgは、OS X 10.10 YosemiteだとOSバージョンチェックによってインストールできません。

ただ、使いたい時もあるはず。
私はRubyMineをJava7で動かしたかったので、なんとかバージョンチェック回避できないか探したら出来たのでメモ。

pkgutilでexpandして加工

pkgが入ったdmgをダウンロード。

Oracle - jdk-7u67-macosx-x64.dmg

中のJDK 7 Update 67.pkgをDesktopなどにコピー。

または

cd ~/tmp
wget http://download.oracle.com/otn-pub/java/jdk/7u67-b01/jdk-7u67-macosx-x64.dmg
open jdk-7u67-macosx-x64.dmg
cp /Volumes/JDK\ 7\ Update\ 67/JDK\ 7\ Update\ 67.pkg ~/tmp

そして、pkgutilコマンドでアンパッケージ。
中を加工します。

pkgutil --expand JDK\ 7\ Update\ 67.pkg JDK\ 7\ Update\ 67.unpkg
vi JDK\ 7\ Update\ 67.unpkg/Distribution

6行から93行目辺り(以下の部分)を削除。

    <installation-check script="pm_install_check();"/>
    <script>// check if this is a downgrade from current version installed, return true
function isDowngrade() {
    try {
        var tInstallVersion = "1.7.67.01";
        // get current installed JavaAppletPlugin bundle
        var bundle = system.files.bundleAtPath("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin");
        if(bundle != null) {
            // check if Info.plist file is present, we need this in case the plugin was not installed properly
            if(!system.files.plistAtPath("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Info.plist")) {
                return false;
            }
            // check if Oracle JRE is installed not by someone else
            if (bundle.CFBundleIdentifier == 'com.oracle.java.JavaAppletPlugin') {
                var tCurrentVersion = bundle.CFBundleShortVersionString;
                // check if current plugin being installed is a downgrade
                var tVersionResult = system.compareVersions(bundle.CFBundleVersion, tInstallVersion);
                if(tVersionResult > 0) {
                    // This is a downgrade return true
                    return true;
                }
            }
        }
    } catch(e) {
        // an exception just occurred
        return (true);
    }
    return false;
}
// Check is current MAC OS X version less than supportedVersion
function checkForMacOSX(supportedVersion) {
    try {
        // Get current ProductVersion
        var tProductVersion = system.version.ProductVersion;
        // Get current ProductName
        var tProductName = system.version.ProductName;

        // Check if current version is less than supportedVersion, if yes Set the result type to Fatal, and give correct message to user

        if(tProductVersion &lt; supportedVersion)
        {
            // Set result values
            var osCheckTitle = system.localizedStringWithFormat('OSCHECK_TITLE');
            osCheckTitle = osCheckTitle.replace("%1$@", tProductName);
            osCheckTitle = osCheckTitle.replace("%2$@", supportedVersion);

            var osCheckMessage = system.localizedStringWithFormat('OSCHECK_MESSAGE');
            osCheckMessage = osCheckMessage.replace("%1$@", tProductName);
            osCheckMessage = osCheckMessage.replace("%2$@", tProductVersion);
            osCheckMessage = osCheckMessage.replace("%3$@", supportedVersion);

            my.result.title = osCheckTitle;
            my.result.message = osCheckMessage;
            my.result.type = 'Fatal';
        }
    } catch (e) {
        // an exception just occurred
        return (false);
    }
    // return true
    return (true);
}


function pm_install_check() {
  if(!(checkForMacOSX('10.7.3') == true)) {
    my.result.title = 'OS X Lion required';
    my.result.message = 'This Installer is supported only on OS X 10.7.3 or Later.';
    my.result.type = 'Fatal';
    return false;
  }
  return true;
}



function pm_choice1_selected() {
  result = true;
  result = result &amp;&amp; (isDowngrade() == false);
  return result;
}


function pm_choice1_enabled() {
  result = true;
  result = result &amp;&amp; (isDowngrade() == false);
  return result;
}</script>

pkgutil flattenで元に戻す

pkgutil --flatten JDK\ 7\ Update\ 67.unpkg JDK\ 7\ Update\ 67-nocheck.pkg

その後、JDK Update67-nocheck.pkgを開いてインストールに進むと、バージョンチェックなくインストール可能です。

注意

常識的な知識なのかもしれませんが、困っている方はどうぞ。

ただおすすめはしません!
私はRubyMineを軽くしたくて遊んでみただけですので、責任は持ちません!

5
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5