SkillAgentSearch skills...

Jar2app

Convert any Java jar to a Mac OS X .App bundle. No external tools needed, no funky parameters, it just works.

Install / Use

/learn @Jorl17/Jar2app
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

jar2app

jar2app is a Python 2/3 script that can easily convert any jar file into a Mac OS X app file. It seeks simplicity, and in fact can be run just like

jar2app input.jar

creating input.App in the process. No third-party libraries. No cruft.

Though simple and easy to use, there are loads of configurable options, such as setting icons, bundle names or bundling your own JRE/JDK.

Install instructions can be found here. Example usage can be found here.

It should run in any operating system (Windows, Mac OS X, Linux), but of course you'll only test the results in a Mac OS X system.

Table of Contents

(TOC created with the help of gh-md-toc)

Aren't there other tools that do this? Why another one?

There are other tools that do this. I acknowledge them and even have several links to them.

However, this project was born out of the need to do something easily and without much cruft. Most solutions out there require a gazillion arguments, or installing ant and memorizing lots of conventions. jar2app, however, tries to keep the power of those utilities while providing high simplicity in the process. Really, isn't it wonderful to have such an easy-to-use interface?

If you're also considering why these contributions weren't just sent to one of the other projects, it is because this could not be done easily. Packr uses a custom launcher and is meant to pack things for Mac OS X, Windows and Linux. Most of the other alternatives require third-party tools that embed other functionality and which simply cannot be stripped. The solution I was left with was just rolling out my own. If you think that's just a strong case of NIH, feel free to grab what you want from me and send a patch to the other projects :) Just follow the GPL!

Can I submit bundles created with jar2app to the Appstore?

jar2app may bundle your jar, but there are several steps you further need to take to submit your application to the Appstore. This is not a limitation of jar2app, it's just how the Appstore requires you to do things. For more information on how to submit bundles to the appstore, see here and here.

How do I install/uninstall it?

Just clone the repository and run install.sh, or uninstall.sh to remove it. It will install to /usr/bin, but you can change this by passing your desired prefix to install.sh, as an argument. This will install the jar2app application/script and make it available for you to run.

Examples:

Install

git clone https://github.com/Jorl17/jar2app
cd jar2app
chmod +x install.sh uninstall.sh
sudo ./install.sh

Install to /usr/local/bin prefix

git clone https://github.com/Jorl17/jar2app
cd jar2app
chmod +x install.sh uninstall.sh
sudo ./install.sh /usr/local/bin

Uninstall

./uninstall.sh

Uninstall from /usr/local/bin prefix

./uninstall.sh /usr/local/bin

How does it work?

jar2app relies on JavaAppLauncher (although you don't need to install anything). This application, officially provided by Oracle (previously Apple), acts as wrapper that starts a JVM with a set of options. The JVM can be bundled with the App file, or the system-wide-one can be used. Essentially, all that jar2app has to do is create a directory structure (app files are just directories), pack JavaAppLauncher and your application in it and set appropriate values in an Info.plist file. Additionally, if you so wish, your own JDK or JRE can be bundled and the Info.plist file will be updated to reflect this.

I know that there are other solutions that write their own wrapper, but the provided wrapper seems to work great (it's also bundled by Weka). The other wrapper I saw out there was from the Packr project and it really depended on their way of doing this.

What exactly can I change?

You can change many things, but more specifically, you can change the icon, the display name (the one that appears on the menu bar), the version and copyright information, the bundled JDK/JRE and the JVM options. For a full list of options, see here

Does jar2app bundle its own JRE/JDK? Can I bundle my own?

By default, jar2app doesn't bundle any JRE or JDK, and the default will be used on each system. You can, however, pass it a JRE/JDK with the -r,--runtime option. It can be supplied as a folder or as a zipfile. This JRE/JDK should match the directory structure found in Oracle's JDK (i.e. the first folder should be named Contents, etc).

Does jar2app figure the main class of my jar automatically? Can I change it?

Yes it does. It looks inside your jar file for the MANIFEST.MF file and extracts the name of the main class. You can change this behavior, and pass in another main class with the -m, --main-class option.

Apple defines several keys for its App format. How does jar2app figure them out?

There are several keys that Apple defines, and you might want to check them out. jar2app assigns values to the following keys:

  • CFBundleDevelopmentRegion: This is fixed at English
  • CFBundleExecutable: This is internally defined to JavaAppLauncher (from oracle)
  • CFBundleIconFile: This is set to whichever icon you passed in, and ignored if no icon is used
  • CFBundleIdentifier: This is chosen from the following, in order:
    1. What you supplied (-b,--bundle-identifier)
    2. The default: com.jar2app.example.application name
  • CFBundleDisplayName: This is chosen from the following, in order:
    1. What you supplied as display name (-d,--display-name)
    2. What you supplied as bundle name (-n,--name)
    3. The name of the app (passed as outputfile argument)
    4. The name of the jar (excluding extension)
  • CFBundleName: This is chosen from the following, in order:
    1. What you supplied as bundle name (-n,--name)
    2. What you supplied as display name (-d,--display-name)
    3. The name of the app (passed as outputfile argument)
    4. The name of the jar (excluding extension)
  • CFBundleVersion: This is chosen from the following, in order:
    1. What you supplied as version (-v,--version)
    2. What you supplied as short version (-s,--short-version)
    3. The default: 1.0.0
  • CFBundleShortVersionString: This is chosen from the following, in order:
    1. What you supplied as short version (-s,--short-version)
    2. What you supplied as version (-v,--version)
    3. The default: 1.0.0
  • CFBundleSignature: This is chosen from what you supply or the string "????".
  • NSHumanReadableCopyright: This is set to what you supply or the empty string

The info.plist file will contain additional keys, but there are used to pass information to JavaAppLauncher (JVM arguments, JDK/JRE, etc)

If I only pass the jar and no other options, what are the defaults used by jar2app?

jar2app assumes that you want to create an app file with the same basename as your jar file and in your current working directory. It assumes no JRE/JDK is to be bundled, and that n

View on GitHub
GitHub Stars419
CategoryDevelopment
Updated15d ago
Forks57

Languages

Python

Security Score

95/100

Audited on Mar 18, 2026

No findings