MacOS – How to direct an app to use a specific Java version

configurationjavamacos

I got an Java application that does run under Java 1.8 without problems when I start its JAR directly.
However on my Mac the JAR is wrapped within an app that demands me to install Java 1.6 — which I really do not want to do!

So I'm searching the point within the app package where I could configure that my App shall use the installed Java 1.8

Changing property InfoDictionary version within Contents/Info.plist to 8.0 will not help.

Is this possible at all or do I need to build a complete new App Package?
In case of the later, which tool would be best to do this for a bunch of applications?

Best Answer

It seems that Oracle could have fixed this. But didn't ...

So I got it working now doing this: (All credits go to: https://oliverdowling.com.au/2014/03/28/java-se-8-on-mac-os-x)

I assume you got the latest JDK installed (currently 1.8.0_60, please adjust this in future)

Change content of Info.plist:

Open Terminal and issue this command

sudo nano /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Info.plist

Look for key JVMCapabilities and change it to this:

<key>JVMCapabilities</key>
<array>
    <string>CommandLine</string>
    <string>JNI</string>
    <string>BundledApp</string>
</array>

Add a symlink for libjvm.dylib and libserver.dylib:

Open Terminal and issue these two commands:

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