简体   繁体   中英

On a Mac, how do I create icon that will take a .jar file, open a terminal, and run that .jar file?

Long story short, I have created a text-based-game, and I want to make it easily transferable to friends' computers.

I don't want to have to give instructions on how to open a terminal and run the file. Can you provide step-by-step instructions on how to (at the minimum) be able to double click the DustToDiamonds.jar file to have it run in the terminal or to (ideally) be able to create an actual icon to be pressed which causes a terminal to open and run the game?

As of now, when I double click on the .jar file I get a popup window with the following error: "The Java JAR file "DustToDiamonds.jar" could not be launched . Check the Console for possible error messages."

I used eclipse to create a .jar for me, and when I run jar -jar DustToDiamonds.jar in the terminal it runs. I don't know anything about Application Bundling or shell commands, so if those are necessary I would need actual code to work off of. I am using a Mac running El Capitan.

Thanks in advance!

You can use some 3rd-party solution to bundle your application into an executable. For example, you can try a packr .

Earlier, it was passible to use a JarBundler, but it is not provided with newest version of MacOS. If you, possibly, use a Gradle as build tool, you can use this plugin to create executable .app. There is like the same solution for the Ant scripts and I suppose you can find something for Maven, if you need it.

As an alternative, you can create a shell script, like for any unix-system, and make it executable. You van find an example here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM