Problems wrapping a jar file into an app bundle

Discussion in 'Mac Programming' started by iindigo, Jan 18, 2012.

  1. iindigo macrumors 6502a


    Jul 22, 2002
    San Francisco, CA
    First of all, just let me say that I apologize if I misuse any Java terminology. It's not my field of expertise - I'm an Obj-C/Cocoa guy, so some Java stuff gets me completely lost.

    I'm trying to make a Java app that I use frequently a little more Mac friendly. Normally, it's just a bare .jar and so lacks many things, such as a proper app name, dock icon, and Mac menubar usage.

    I still have a copy of the Jar Bundler included with Xcode 3. The bundles it produces work nicely for the most part, but it has a problem with this particular jar file. For whatever reason, the Use Macintosh Menu Bar option doesn't work. In fact, it's completely ignored, and the app's menus remain attached to its window.

    I do not have access to the source.

    What could cause the menubar option to fail? Is there anything I can do without first acquiring the source?

    P.S. It's no big deal if it's not possible, but is there some way I can force the application to use native (or closer to native) file dialogs instead of the mediocre-at-best standard Java ones?
  2. foidulus macrumors 6502a

    Jan 15, 2007
    Is the menu bar there when you launch it as a jar? You can set a Java system property that will enable/disable the menu bar at the top of the screen, the default is to put it on the top, but if the coders set that system property then it won't appear there.
  3. iindigo thread starter macrumors 6502a


    Jul 22, 2002
    San Francisco, CA
    Yeah, the menubar is on the window when I launch the bare jar file.
  4. thundersteele macrumors 68030

    Oct 19, 2011
    Automator can do this.

    Open Automator, create a new application, then drag the "run shell script" into the window on the right. In the "run shell script" window, type

    java -jar /path/to/app.jar

    I'm not sure if something else is needed for java, but this is how I created launch icons for some of the macports I installed.
  5. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    If you told us exactly what the Java app was, and the URL of where to get it, then maybe someone could take a closer look at it.

    Without specifics, all anyone can do is guess about why it's not doing what you want.
  6. nehalvpatel macrumors newbie

    Aug 15, 2010
    I ran into a similar problem, and I did this (I'm not sure if that's exactly what you wanted, but here you go!):
    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
        system("open /Applications/name.jar");
        [NSApp terminate:(0)];
    All it does is launch the .jar and then quit the current app. :D
  7. foidulus macrumors 6502a

    Jan 15, 2007
    ok, so it's not set in the code then. Try adding this to the <Properties> section of the Info.plist file in the .app directory:

    That will tell the app to use the screen menu bar.

Share This Page