9

Just this. I have an executable jar that I'd like to create a .app folder for. Mainly just because I'd like it to be pinnable to the dock.

Is there any easy way to do this?

Edit: Really what I'm looking for, is a mac shortcut. But apparently on the .app folders can be pinned to a dock.

4 Answers 4

8

If you want an easy way without need of third-party apps:

  1. Launch AppleScript editor

  2. Write the following:

    --do shell script "java -jar /Contents/execute.jar"

I commented that line out because we have yet to put the jar there. Save as application. Now Right click on produces .app file -> Show Package Contents, go to Contents and drag the .jar file there. Now go to Resources -> Scripts -> main.scpt and open that. Now remove the double dash (--), compile and save.

If it doesn't launch, try executing in terminal chmod 777 <path to jar file> simply drag the jar into Terminal.

For macOS Monterey (12.5) and other recent OS the tool is now called "Script Editor". Once you have a working script, saving as an Application makes it executable. This app has been around for decades, and was originally called AppleScript editor.

5
  • Wait, I think I figured it out. I add the line to a script called my_script.scpt. And run it from the terminal with osacript my_script.scpt . I'll mark this answer as correct once I test it out. Thanks!
    – dessalines
    Jun 15, 2015 at 12:47
  • open /path/to/java.app Or simpler double click it. You can open any app with the open command.
    – John K
    Jun 15, 2015 at 12:47
  • Well it turns out this doesn't solve my problems. .scns scripts aren't pinnable to the dock as applications, and you can't change their icons. They do no better than just double clicking the jar in the first place.
    – dessalines
    Jun 15, 2015 at 12:55
  • Pretty helpful answer, however I needed to place the full path from the root of my machine to get this to work for me. Dec 16, 2016 at 16:05
  • 1
    Keep in mind that you need the Java JDK installed for this to work. I tried to run it in the command line and was prompted to install it.
    – Hendeca
    Jul 23, 2019 at 15:33
3

How about Platypus?! It can pack "all" kinds of things, jar, py, script etc download from http://sveinbjorn.org/platypus, its GUI is relatively easy to follow. enter image description here

1
  • 1
    Welcome to Ask Different! We're trying to find the best answers and those answers will provide info as to why they're the best. Explain why you think the answer you provided will solve the problem or is better than others out there. Providing links can also help the OP, and others, find additional info for themselves. See How to Answer on how to provide a quality answer. - From Review
    – fsb
    Dec 29, 2016 at 21:35
0

Do you have access to the source? If so, you can try the appbundler.

https://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html

Or the Jar Bundler: https://developer.apple.com/library/mac/documentation/Java/Conceptual/Java14Development/03-JavaDeployment/JavaDeployment.html

2
  • Thejar bundler was for Java 6 and earlier and is not,available now
    – mmmmmm
    Jun 15, 2015 at 9:00
  • Yep, this is unusable for me.
    – dessalines
    Jun 15, 2015 at 12:56
0

Take a look at Packr. I think it does exactly what you need https://github.com/libgdx/packr.

0

You must log in to answer this question.

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