Docear on macOS: Navigating the Apple Java Nightmare

So this blog post will be brief, as I suppress my disdain for Apple’s attitude towards Java, now that they no longer need it to survive due to their App Store ecosystem.

This blog post documents how I was able to get the Docear Mindmapping software working on OSX El Capitan (10.11).

Sadly, many Java applications which should ‘run anywhere’ simply don’t anymore on the Mac.  Apple abandoned their own internal version of the JRE and bundling with the OS, and deferred said support to the author of Java, now Oracle.  Oracle, too have contributed to the nightmare in providing little assistance in making the transition seamless.

After installing Docear on my mac, I attempted to start it with the icon in the Applications folder in the usual way only to find it bounce in the dock once, and disappear.  How rude I thought.  So I resorted to the command line (gotta love UNIX-like desktops).  When I attempted to start it there, I was presented with the ugly error message:

$ /Applications/Docear.app/Contents/MacOS/FreeplaneJavaApplicationStub
JavaVM: Failed to load JVM: /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bundle/Libraries/libserver.dylib
JavaVM: Failed to load JVM: /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bundle/Libraries/libserver.dylib
JavaVM FATAL: Failed to load the jvm library.
[JavaAppLauncher Error] JNI_CreateJavaVM() failed, error: -1

Just lovely.  I actually thought I was running Java JRE 1.8 that I downloaded from Oracle.  Seems there are other versions lurking on my system.

I’ll spare you all the drudgery of diagnosing this issue and coming up with a solution.  I will tip my hat to Oliver Dowling and his blog post which eventually lead me to the solution below.  One thing I did learn is that creating a symbolic link for libserver.dylib did not work for me.  I had to instead create a hard link.  I suspect the JRE stub FreeplanJavaApplicationStubJavaVM binary was checking for the existence of a ‘normal’ file rather than ‘a’ file.

Anyway, here are the goods to make Docear work on OSX10.11 (and hopefully other versions).  Be sure to substitute the Java version numbers in the file paths with your version of Java installed.

$ cd /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home
$ sudo ln -s jre/lib bundle
$ cd bundle
$ sudo mkdir Libraries
$ sudo ln /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/jre/lib/server/libjvm.dylib libserver.dylib

Hopefully after executing these commands, you will be able to use Docear.  Good luck!

Arrow key scroll in Mac Excel

Ever been using Microsoft Excel on the Mac and found that when you use the arrow keys on the keyboard to move from one cell to the next, instead the whole worksheet scrolls?

This is actually a feature of Microsoft Excel carried over from the Windows version on which you press the Scroll lock key to enable or disable.  Older Macintosh computers had the F14 key mapped to the Scroll lock key of PC keyboard, so it was quite easy to enable or disable.  However newer Macintoshes no longer have a F14 key.

This makes disabling this feature tricky to say the least.

In the past I have attached an older Mac keyboard to my 2010 Macbook Pro and pressed the F14 key.  However for those of you who do not have ready access to such legacy keyboards, you can use a simple applescript application that I have written called Excel Scroll Lock.

What it does is “send” a Shift-F14 key press to Microsoft Excel as if you pressed the Scroll lock key, thus toggling on or off this function within Excel.

To use, simply download the application, unzip, and drag the application into your Applications folder.  Then run it.  You can alternatively download a disk image version of the application, and run without installing into your Applications folder.

For those interested in the applescript, it is shown below, and also included in the downloaded application bundle under the Contents/Resources/Scripts folder.  The script is also available on github – contributions welcome.

--Applescript to fix scroll-lock problem with Microsoft Excel on Mac OS
--Written by Damien Clark (https://damosworld.wordpress.com)
--Licenced under GPLv2 (http://www.gnu.org/licenses/gpl-2.0.html)
--18th of June, 2012

--From time to time you may find that using the cursor keys in MS Excel for Mac will 
--scroll the worksheet, but not shift the selected cell.  This is a feature of Excel 
--that is enabled by pressing the Scroll Lock key.  On Macintosh computers once upon 
--a time, F14 was the equivalent key to Scroll lock on the PC.  Modern Macintosh 
--computers are no longer furnished with an F14 key, and while I am sure there is a 
--keyboard combination to emulate F14, I have yet to find it.  As a result, you can 
--find yourself stuck with this special scroll lock mode of Excel and it is very 
--frustrating.  This script effectively "sends" an F14 keypress to Microsoft Excel, 
--thus turning on or off this scroll lock feature.  So if you find yourself in this 
--situation, you can execute this program to toggle the feature on and off as 
--necessary.  Simply run the application and click OK.  

set returnedItems to (display dialog "Press OK to send scroll lock keypress to Microsoft Excel or press Quit" with title "Excel Scroll-lock Fix" buttons {"Quit", "OK"} default button 2)
set buttonPressed to the button returned of returnedItems

if buttonPressed is "OK" then
    tell application "Microsoft Excel"
        activate --Make it the active application to receive System keyboard events
    end tell
    tell application "System Events"
        key code 107 using {shift down} --Send the F14 key which is scroll-lock on Mac keyboards
    end tell
    activate
    display dialog "Scroll Lock key sent to Microsoft Excel" with title "Mac Excel Scroll-lock Fix" buttons {"OK"}
end if