2

I wrote a small Java desktop application using NetBeans, Java 8 and JavaFX 8 on my MacBook running macOS High Sierra. I can launch it from Terminal by executing a Bash script (mentioned below), but double clicking on the JAR in Finder fails (right clicking and selecting Open fails too) and I receive a suggestion that I look for errors in Console.app, but get no other clue as to what's failing. It's a very specialized app that I'll probably only distribute to a couple of co-workers who don't work in Terminal.

Google search has given me solutions that are out of date, the Oracle solution (out of date) provided a link that proved useless.

What do I need to do to be able make the JAR file executable from Finder? How can I get more information on what's wrong? Since it's not signed it might be that Gatekeeper is the culprit.

My script is in ~/bin which is included in PATH. I have a folder, ~/jars for Java apps, each of which has its own folder. In that folder I have copied my project-> ... dist app.jar and my libs folder that has external jar libraries. The script has execute permissions. Here is the script:

#!/bin/bash
java -jar $HOME/jars/myApp/myApp.

I can launch the app from Terminal or from Finder but the first time finder will think I want to edit it so I must choose Other and then choose Terminal. BTW it works exactly the same in Ubuntu, I just copied the script, dropped it into ~/bin, and dropped the myApp folder in ~/jars. It mostly ran but the JRE on the Ubuntu machine, while Java 8, is a little older version than the one on my Mac and I get a run time error after a while. I think that updating to the same version will solve the problem as I don't know how to force NetBeans to include the JRE.

5
  • 1
    Instead of double clicking to run the file, try right clicking and selecting open.
    – Nimesh Neema
    Commented May 8, 2018 at 0:33
  • @NimeshNeema Thanks, I tried that, too, and have edited my question. Commented May 8, 2018 at 14:09
  • Can you share the Bash script that you use to launch the app?
    – Nimesh Neema
    Commented May 8, 2018 at 14:28
  • @NimeshNeema Done! Commented May 8, 2018 at 23:27
  • You can find Console.app under Utilities folder in /Applications. Alternatively, invoke Launchpad, open Other folder and you can find Console app there. Console app is a log viewer for macOS.
    – Nimesh Neema
    Commented May 9, 2018 at 6:56

1 Answer 1

1

In my case, I had a Netbeans app that I developed in Snow Leopard and was unable to open by double-clicking in High Sierra.

Instead of copying over just the app's .jar, I copied the dist directory that contained the app's .jar plus the library directory that contains 6 other .jar files that were added when I originally compiled the distribution version.

Double-clicking the app's .jar still didn't work, but I was able to launch "my_app.jar" from the terminal by cd-ing into the dist directory and using

java -jar my_app.jar

(NB: I have the latest JDK installed.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .