Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So, I double click on my jar file and it just blinks a window with white screen then it disappears. After that, I right-click and select "Open with jar launcher" it is the same. too. I opened up Terminal and type java -jar "System FRONT.jar" then it opened up perfectly.

I want it to be opened directly when double clicking it! How do I do that?

share|improve this question
It probably opens a terminal window, finishes and then closes the terminal window. – The Unfun Cat Sep 24 '12 at 11:33
To debug in - goto Preferences->Settings choose the Shell tab and Alter the "When the Shell exits" option then the terminal will stay open – Mark Sep 24 '12 at 12:20

You can prepend a short script to the .jar to make it executable via double click. In Terminal do the following:

$ cat > header-template <<"EOF"

exec java -jar $0 "$@" > /dev/null

$ cat header-template "System FRONT.jar" > executable_app
$ chmod +x executable_app

Double-clicking executable_app should now launch the application.

Why does this work in the first place? Well, a .jar is just a .zip archive which gets unpacked and executed by java. And the zip format allows to prepend additional stuff in front of the actual archive. Any zip unarchiver skips this part until it finds the start of the archive (indicated by PK...).

share|improve this answer

The best way to make a java gui application work with OSX is to bundle it as an application. This requires Jar which on Lion is at /usr/share/java/Tools/Jar I think it is installed as part of Xcode but appears not to be in Apple's current documentation so might not now be supported. Old documentation is here

There do appear to be ant tasks to do this in appbundler which is documented in the Oracle JavaSE documentation.

share|improve this answer
Actually its a game. So how do I make people double-click on it and open up my jar without commands? – SystemNetworks Sep 24 '12 at 12:25
Other users will prefer it as an OSX app rather than just a .jar. In this case you do it once as part of the build process and users do not have to do anything – Mark Sep 24 '12 at 12:27


You can use packr to package up your jar for easy distribution and double-clicking to open:

Packages your JAR, assets and a JVM for distribution on Windows (ZIP), Linux (ZIP) and Mac OS X (.app), adding a native executable file to make it appear like the app is a native app. Packr is most suitable for GUI applications, such as games made with libGDX

packr has been discussed on Hacker News and is an open source project.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.