How to direct an app to use a specific Java version?
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?
Solution 1:
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
Solution 2:
This might help jump-start finding an answer. Recalling that PyCharm.app does something similar, here is an extract from the applications Info.plist
file (watch the …snip… lines in there):
…snip…
<key>JVMOptions</key>
<dict>
…snip…
<key>JVMVersion</key>
<!-- string>1.6*,1.7+</string -->
<string>1.7+</string>
…snip…
</dict>
…snip…
Also, the PaperCut Client application (PCClient) uses some simliar items in its Info.plist
:
<plist version="1.0">
<dict>
…snip…
<key>CFBundleExecutable</key>
<string>JavaAppLauncher</string>
<key>JVMRuntime</key>
<string>jre</string>
<key>JVMMainClassName</key>
<string>biz.papercut.pcng.client.uit.UserClient</string>
<key>JVMOptions</key>
<array>
<string>-Dclient.home=$APP_ROOT/Contents/Resources/</string>
<string>-Dcom.apple.macos.useScreenMenuBar=true</string>
<string>-Xmx256m</string>
<!-- Workaround since the icon parameter for bundleapp doesn't work -->
<string>-Xdock:icon=$APP_ROOT/Contents/Resources/client-icon.icns</string>
</array>
<key>JVMArguments</key>
<array/>
</dict>
</plist>
Again, these are parts of different Info.plist
files so they might not work as straight copy-and-paste. However, both apps work on OS X, so these keys/values might help you narrow down to a working solution.
Both apps seem to have a slightly different way of doing things. PCClient.app appears to include it's own version of Java, whereas PyCharm relies on what’s installed on OS X.