Java – Run .jar files on Mac Big Sur with a single click

Run .jar files on Mac Big Sur with a single click… here is a solution to the problem.

Run .jar files on Mac Big Sur with a single click

I recently switched from Windows to Mac and tried to open an executable .jar file on my Mac by clicking the icon in the Finder. Somehow, Mac cannot execute .jar files unless using a terminal.

After some research, I knew that “javapackager” and “Jar bundler” were the way to make it workable, but I couldn’t find any features of these programs to download.

So is there a way to make these programs work?

Solution

The distribution model of sending jar files to users and then expecting them to know how to use it is outdated – Oracle more or less acknowledges this, and the vast majority of desktop Java applications are not, and never have been, deployed this way: they have stopped supporting the idea of “JRE”. This is more or less formal (explicitly recognized in Oracle’s products) how it used to work:

  • An application developer makes a Java application, converts it into a bunch of jar files, and sends it as a zip file or using an extremely simple installer that simply copies them somewhere.
  • Application users sign a contract with Oracle to download the JRE; Maintenance of this JRE (because someone needs to update that thing or at least tell the user that there is a security vulnerability in it, if that happens) is entirely an arrangement between the user (or possibly the OS maintainer) and the oracle; The application developer is not involved and has no control over it.
  • If there is no JRE available, the user has to handle it themselves, and the application developer has no real control over it.
  • App developers more or less just pray that their app will run fine on any JRE used when double-clicking their jar. If the version is wrong, you cannot include legacy or similar notifications, or even meaningfully specify the version of Java that you are compatible with in the jar file.

This is obsolete because Oracle has stopped shipping JEs and no longer wants “Hooks” to have relationships with every end-user system on the planet to support those JREs.

So you are working under the old deployment mechanism. If you are the owner of this application, update to a new model (e.g. make a .app using jlink and jpackager and publish it in the .dmg , just like a normal Mac app, plus, this allows you to sign, have a nice icon, etc.). If you’re not, it’s time to talk to the maintainers of this app and tell them to do so. Until then, you can resolve this issue in the following ways:

  • Go to https://adoptopenjdk.net and download an openjdk.
  • Install it.
  • Schedule a recurring appointment in your schedule: Visit adoptopenjdk.org about every month and check for updates. Uninstall the OpenJDK you own and install a new one. Failure to do so means that your system could be compromised. AdoptOpenJDK isn’t really good for this kind of thing (nothing is true other than Oracle’s JRE8, but [A] it’s 10 years old at this point, and [B] Oracle has stopped supporting it, or will soon stop supporting it This is also a security issue), so you have to put in the effort.
  • Double-click jar.

Related Problems and Solutions