Java 7 and other modern(ish) software on OS X 10.7 Lion

I have an old “Mid-2007” MacBook (Core 2 Duo, upgraded with 3GB RAM and a 60GB SSD), that’s well past its prime, but still works fine. (The battery, swapped in 2015, only has 25 cycles on it.) I gave up trying to get Linux installed on it, and although somewhat more modern versions of OS X have been hacked to work on it, Lion works well enough for most things and is actually supported, vs. being a mostly-working-but-broken-in-various-aspects hack. (I respect a good hack, but when the screen doesn’t redraw properly...) So, it’s a frozen in time machine running OS X 10.7.5, “Lion,” an operating system dating back a decade or so.

All is not lost, though.

I installed Arctic Fox for web browsing. Frustratingly, because GitHub has deprecated older TLS mechanisms, I had to download the browser on another machine and copy it over using Screen Sharing. (I get the impetus behind HTTPS Everywhere, but for simply retrieving open source code from a site like GitHub, in my opinion users should have the option of using HTTP, to avoid issues like this.)

I pulled down NetBeans 7.4, which will run on Lion, but requires Java 1.7.0 update 10 or newer. Okay. (PhpStorm will run, at least up to 7.1.)

Java 6 is still available from Apple, as Java for OS X 2017-001. Needed that before I could run the “unofficial OpenJDK 7” installer. (I tried setting up homebrew - requires 10.10 or later. I tried installing MacPorts for Lion (as of July 2020, MacPorts builds installers for systems as far back as 10.4, Tiger), which works (needs XCode installed; I used the 4.2.1 installer), but openjdk8 complains it can only be installed under 10.10 or later.)

Downloaded and installed, with the somewhat arcane process I detail below, but then realized I could and should have just downloaded the bundle not the installer. Yeah, but I didn't do that, so, here are the steps I took to get the manually installed OpenJDK 7 visible to the Mac’s /usr/libexec/java_home:

$ cd openjdk-1.7.0-u80-unofficial-macosx-x86_64-installer
$ ./install


Installed the OpenJDK to /Users/flying-geek/openjdk_1.7.0_u80/ Verify it works:

$ /Users/flying-geek/openjdk_1.7.0_u80/bin/java -version
openjdk version "1.7.0-u80-unofficial"
OpenJDK Runtime Environment (build 1.7.0-u80-unofficial-b32)
OpenJDK 64-Bit Server VM (build 24.80-b11, mixed mode)


But, Apple’s Java integration doesn’t see it (so the installer for NetBeans will fail complaining it needs Java 7):

$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):

    1.6.0_65-b14-462, x86_64:    "Java SE 6"    /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_65-b14-462, i386:    "Java SE 6"    /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

Let’s tell the operating system about our new Java install:

$ sudo mkdir -p /Library/Java/JavaVirtualMachines/openjdk-1.7.0.jdk/Contents/MacOS
$ sudo ln -s /Users/flying-geek/openjdk_1.7.0_u80/ \
 /Library/Java/JavaVirtualMachines/openjdk-1.7.0.jdk/Contents/Home

$ sudo ln -s /Users/flying-geek/openjdk_1.7.0_u80/jre/lib/jli/libjli.dylib \
 /Library/Java/JavaVirtualMachines/openjdk-1.7.0.jdk/Contents/MacOS/libjli.dylib

$ sudo cp /Users/flying-geek/Downloads/homebrew-openjdk-1.8-info.plist /Library/Java/JavaVirtualMachines/openjdk-1.7.0.jdk/Contents/Info.plist


The info.plist file I copied from here, and tweaked:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>English</string>
        <key>CFBundleExecutable</key>
        <string>libjli.dylib</string>
        <key>CFBundleGetInfoString</key>
        <string>OpenJDK 1.7.0_80</string>
        <key>CFBundleIdentifier</key>
        <string>net.java.openjdk.1.7.0.jdk</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>7.0</string>
        <key>CFBundleName</key>
        <string>OpenJDK 1.7.0</string>
        <key>CFBundlePackageType</key>
        <string>BNDL</string>
        <key>CFBundleShortVersionString</key>
        <string>1.0</string>
        <key>CFBundleSignature</key>
        <string>????</string>
        <key>CFBundleVersion</key>
        <string>10.0.2</string>
        <key>JavaVM</key>
        <dict>
                <key>JVMCapabilities</key>
                <array>
                        <string>CommandLine</string>
                </array>
                <key>JVMMinimumFrameworkVersion</key>
                <string>13.2.9</string>
                <key>JVMMinimumSystemVersion</key>
                <string>10.6.0</string>
                <key>JVMPlatformVersion</key>
                <string>1.7</string>
                <key>JVMVendor</key>
                <string>Oracle Corporation</string>
                <key>JVMVersion</key>
                <string>1.7.0_80</string>
        </dict>
</dict>
</plist>

Now, it shows up:
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (3):
    1.7.0_80, x86_64:    "OpenJDK 1.7.0"    /Library/Java/JavaVirtualMachines/openjdk-1.7.0.jdk/Contents/Home    1.6.0_65-b14-462, x86_64:    "Java SE 6"    /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_65-b14-462, i386:    "Java SE 6"    /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home


And NetBeans 7.4 installed happily.

I haven’t tried it yet, but in theory, with Java 7 as a boot environment, OpenJDK 8 should be installable. But that’s for another lazy Sunday afternoon.

Meanwhile, LibreOffice 4.3.6.2 will run happily on Lion, and is a pretty robust office suite.

PHP 7.4 is available through MacPorts:

$ port search php
php74 @7.4.4 (lang, www)
    PHP: Hypertext Preprocessor
$ sudo port install php74

...
$ php74 -version
PHP 7.4.4 (cli) (built: Mar 26 2020 16:17:53) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies


Likewise MariaDB (mariadb is version 5.5.68 as of this writing, with 10.0.38_1 through at least 10.4.13 available as well), etc.

TextWrangler 4.5.12 is the latest version that will run on Lion.

FileZilla 3.24.1 is the last version that will run on Lion.

Eclipse Luna runs happily; later versions probably do as well but 4.4.2 (build ID 20150219-0600) is the latest I’ve tested.

This is never going to be my full-time computer, but for some limited uses (iMovie capturing using the built-in Firewire, light web browsing, some coding, some command line stuff), it’s a very usable machine. Certainly more productive than trying to sling code or write a legal brief on an iPad (which can be done, I’ve done it, but I’m always more productive with a full windowing system, external Bluetooth mouse (my Logitech M535 works flawlessly), and real, full-sized keyboard (external mechanical FTW, but the built-in keyboard doesn’t totally suck, either)...

Update: Java 8 installed in pretty much the same way. Combining guidance from here and here:

$ sudo port install mercurial
$ hg clone http://hg.openjdk.java.net/jdk8/jdk8
$ cd jdk8
$ chmod 755 get_source.sh
$ ./get_source.sh
$ bash ./configure
$ CPATH="/usr/X11/include" LANG=C make ALLOW_DOWNLOADS=true ALT_BOOTDIR=`/usr/libexec/java_home -v 1.7+` HOTSPOT_BUILD_JOBS=`sysctl -n hw.ncpu` # This is used because OpenJDK7 was installed (see above). But this version complaints ALT_ variables are deprecated, so ...

$ make all
$ make install

$ /usr/local/jvm/openjdk-1.8.0-internal/bin/java -version
openjdk version "1.8.0-internal"
OpenJDK Runtime Environment (build 1.8.0-internal-chris_2020_07_26_16_52-b00)
OpenJDK 64-Bit Server VM (build 25.0-b70, mixed mode)

$ sudo mkdir -p /Library/Java/JavaVirtualMachines/openjdk-1.8.0.jdk/Contents/MacOS 

$ sudo ln -s /usr/local/jvm/openjdk-1.8.0-internal/ \
/Library/Java/JavaVirtualMachines/openjdk-1.8.0.jdk/Contents/Home$ sudo ln -s /usr/local/jvm/openjdk-1.8.0-internal/jre/lib/jli/libjli.dylib \
/Library/Java/JavaVirtualMachines/openjdk-1.8.0.jdk/Contents/MacOS/libjli.dylib

/usr/libexec/java_home -V
Matching Java Virtual Machines (4):
    1.8.0, x86_64:    "OpenJDK 1.8.0"    /Library/Java/JavaVirtualMachines/openjdk-1.8.0.jdk/Contents/Home

    1.7.0_80, x86_64:    "OpenJDK 1.7.0"    /Library/Java/JavaVirtualMachines/openjdk-1.7.0.jdk/Contents/Home
    1.6.0_65-b14-462, x86_64:    "Java SE 6"    /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    1.6.0_65-b14-462, i386:    "Java SE 6"    /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home


(The plist file is the same as above, but with 1.8/1.8.0 where 1.7/1.7.0 appear and no minor version.)

Trim:
I grabbed a cheap SSD for this machine (the goal was to make it usable at minimal cost, circa 2015), a $33 60GB “Centon Diamond VS1” (60GB25S3VS1). I enabled trim using Trim Enable 3, which also provides a lot of insight into the parameters and health reports provided by the SSD drive.

Linux: I may give Linux another go, using one of the Matt Gadient modified images. Stay tuned.

Comments

  1. nice! I have the same machine, a brand new battery and can’t wait to fiddle with it. What SSD would you recommend? One with built-in TRIM I’d guess? Lion doesn’t manage TRIM for 3rd-party SSDs I think.

    ReplyDelete
    Replies
    1. Updated the post. Naw, I used a cheap drive. This machine isn't really worth pouring money into. Trim Enabler works to, well, enable trim, on Lion on this hardware.

      Delete

Post a Comment