How can you get java jar file app to run on Big Sur by double-clicking and to access file system?

I wrote a java-for-all-desktops jar application years ago and it worked fine on all java versions and all Mac OS, and Windows versions, until I put the jar file on Big Sur (OSX 11.2), on which I installed a current JRE. At that point, it couldn't read or write from/to the regular file system. On its own, it defaulted to reading and writing only to a tmp area in /private/var... and files stored in that directory automatically deleted after the application was quit and run again. Previously, files were saved to and read from the directory containing the jar file with the option of using jFileChooser to move around the real file system. If I explicitly set the java application it to the start on Desktop and recompiled it, then it could move to different directories but not see or access files within them. What a weird new hassle!


After many hours of screwing around, I figured out how to fix all this based on some posts in stackoverflow here (Thanks!). They didn't solve it, but it gave me clues of what to try.

https://stackoverflow.com/questions/65469536/why-does-a-jar-file-have-no-permissions-to-read-from-disk-when-started-via-doubl


I found the program that launches JAR files when you double-click them in:

/System/Library/CoreServices/Jar Launcher.app


By going into System Preferences -> Security -> Privacy -> Full Disk Access, I was able to navigate to and add the above Jar Launcher.app to the list and then my jar file could be double-clicked

and worked like always with full access to the file system :)


It was not needed to solve my problem, above, but I will note that java works differently when it is run from the command line in Terminal as compared when you double-click a jar file. Java seems to inherit its access from either the Terminal or the Jar Launcher, so the key point is to give Jar Launcher or Terminal the Full Disk Access. In case anyone needs to (?) you can also add java itself and any of its modules to the Full Disk Access list (as above). The easiest way to do this is to launch your jar from the terminal with

java -jar YourProgram.jar , then, when the jar appears in the dock, right click on it and click Open in Finder. This will open the folder with the java executables. Then you can select them with the mouse and

drag them right into the Full Disk Access list. I tried that along the way, but it was neither sufficient nor necessary to get the jars to work properly by double-clicking them, whereas giving the permission to Jar Launcher was. Enjoy! I answered my own question, but I wanted to leave this here to save others the many hours of agony I had before solving this.

iMac Line (2012 and Later)

Posted on Apr 27, 2021 9:45 PM

Reply

Similar questions

There are no replies.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How can you get java jar file app to run on Big Sur by double-clicking and to access file system?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.