installer icon indicating copy to clipboard operation
installer copied to clipboard

Double-click on JAR doesn't launch the application - Mac OS X

Open todivefor opened this issue 5 years ago • 16 comments

Issues 32 and 34 were merged and closed. Those issues were for Windows. The same issue is true for MAC OS X. For Oracle JDK created JAR files, they are launched with "jar launcher.app" (15.0.1) found at /System/Library/CoreServices/Jar Launcher.app. Minor inconvenience, but a difference. I have found this with all AdoptOpenJDK releases on Mac OS X 10.14 and 10.13.

todivefor avatar Apr 24 '19 16:04 todivefor

@todivefor any idea how this would be associated?

gdams avatar Apr 25 '19 06:04 gdams

So I've created a .jar file on my mac and when I double click it, it opens with jar launcher app. That seems to be working for me.

gdams avatar Apr 25 '19 06:04 gdams

Or is this to do with making jar launcher.app use adoptopenjdk Java rather than another vendor?

gdams avatar Apr 25 '19 09:04 gdams

running a test build with this fix: https://github.com/AdoptOpenJDK/openjdk-installer/pull/95

gdams avatar Apr 25 '19 10:04 gdams

@todivefor could you please confirm the fix for me by running the following commands making sure that the INPUT_DIRECTORY variable is set correctly:

INPUT_DIRECTORY=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk
/usr/libexec/PlistBuddy -c "Add :JavaVM:JVMCapabilities:1 string JNI" "${INPUT_DIRECTORY}/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Add :JavaVM:JVMCapabilities:2 string BundledApp" "${INPUT_DIRECTORY}/Contents/Info.plist"

gdams avatar Apr 25 '19 11:04 gdams

@gdams that did not work. I first tried it just like you said and it seemed to work. I then tried it on INPUT_DIRECTORY=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk and it did not work there. I went back to adoptopenjdk-8.jdk and removed the above fix and re-tryed. It worked, so my statement all AdoptOpenJDK releases was false. Double click on 1.8.0_192-b12 works, but 11.0.3+7 does not.

todivefor avatar Apr 25 '19 14:04 todivefor

hmmm okay, do you know if an Oracle Java 11 works with this?

gdams avatar Apr 25 '19 14:04 gdams

I do not, but I can give it a try.

todivefor avatar Apr 25 '19 15:04 todivefor

I tried this on Oracle Java 11, and the bottom line is it operates the same as AdoptOpenJDK 11 (cannot double click jar). I can get both Oracle 11 and AdoptOpenJDK 11 to work if within Netbeans if I have Java Platform set to JDK 11 and Source/Binary Format set to JDK 8. I don't understand this and posted this question on Superuser:

https://superuser.com/questions/1429769/netbeans-java-platform-and-source-binary-format-inconsistency

todivefor avatar Apr 25 '19 20:04 todivefor

Thanks for your help. I'm thinking that I should probably land the change anyway to be consistent with Oracle and then we can do some further investigation.

gdams avatar Apr 26 '19 10:04 gdams

I don't know if this actually helps the issue, but one solution would be to create an extremely simple application in Automator that runs shell script java -jar "$@" when fed a jar file.

CatalinaJarLauncher.zip

You can then just use Get Info on any given jar to set this app as the default for opening jar files (the only side-effect of this is that the icons on jar files themselves will change, but if you don't mind that, this is a pretty good solution).

Here's a screenshot of the actual project in Automator:

Screen Shot 2020-05-23 at 4 36 13 PM

EDIT: If you don't want this file to just clutter up your Desktop or anything, you can place it in ~/Library/Services/, as that is typically where Automator apps go.

LittleCube-hax avatar May 23 '20 20:05 LittleCube-hax

Something changed going from 11.0.8_10 to 11.0.9.1_1 and continues into 11.0.10_9. I have a jar file that I double click and worked until 11.0.9.1_1. I started getting that the jar file needed to be installed in and run from the user's home directory. I just went back to 11.0.8_10. Now I installed 11.0.10_9 and got the same. I guess "jar launcher.app" executed from the directory in which it resided, but now does not. I can execute java -jar xxxxx.jar from within the directory, but double click does not. This is not a big deal, I can work around, just a change.

todivefor avatar Feb 03 '21 17:02 todivefor

@todivefor could you please confirm the fix for me by running the following commands making sure that the INPUT_DIRECTORY variable is set correctly:

INPUT_DIRECTORY=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk
/usr/libexec/PlistBuddy -c "Add :JavaVM:JVMCapabilities:1 string JNI" "${INPUT_DIRECTORY}/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Add :JavaVM:JVMCapabilities:2 string BundledApp" "${INPUT_DIRECTORY}/Contents/Info.plist"

Hey.

I had this same issue, came across this issues thread. Fresh install of Mac OS Big Sur with Adopt Open JDK 11.

$ java -version openjdk version "11.0.11" 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)

I adjusted INPUT_DIRECTORY. I can now launch .jar files with the stock JavaLauncher.app without issue.

jwrb avatar Jun 20 '21 21:06 jwrb

@jwrb what did you adjust INPUT_DIRECTORY to be? Can you also send me your Info.plist

gdams avatar Jun 21 '21 09:06 gdams

@jwrb I would be glad to test. How do I change INPUT_DIRECTORY?

todivefor avatar Jun 21 '21 13:06 todivefor

@jwrb Nevermind

Ran:

PWRMacbookPro:~ userid$ INPUT_DIRECTORY=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk PWRMacbookPro:~ userid$ /usr/libexec/PlistBuddy -c "Add :JavaVM:JVMCapabilities:1 string JNI" "${INPUT_DIRECTORY}/Contents/Info.plist" PWRMacbookPro:~ userid$ /usr/libexec/PlistBuddy -c "Add :JavaVM:JVMCapabilities:2 string BundledApp" "${INPUT_DIRECTORY}/Contents/Info.plist" PWRMacbookPro:~ userid$

Got same result.

todivefor avatar Jun 21 '21 13:06 todivefor