dcsimg
Mac OS X Application bundle for a java app
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Almagest_FUTT
Posted On:   Thursday, July 21, 2005 03:19 PM

Hi folks, This isn't really a question; rather a suggestion for place where to gather information. I recently made meself an automatation for packaging the multi-platform java app i'm working on into a Mac application bundle. This is what it's all about: Create a directory structure like the following: [appname]/ [appname]/Contents/ [appname]/Contents/MacOS [appname]/Contents/Resources [appname]/Contents/Resources/Java where [appname] be the application's desired display-name. This structure has to be filled with the data following: [appname]/Conten   More>>

Hi folks,


This isn't really a question; rather a suggestion for place where to gather information.


I recently made meself an automatation for packaging the multi-platform java app i'm working on into a Mac application bundle.

This is what it's all about:


  • Create a directory structure like the following:
    					
    [appname]/
    [appname]/Contents/
    [appname]/Contents/MacOS
    [appname]/Contents/Resources
    [appname]/Contents/Resources/Java

    where [appname] be the application's desired display-name.



  • This structure has to be filled with the data following:

    1. [appname]/Contents/Info.plist

    2. [appname]/Contents/PkgInfo

    3. [appname]/Contents/MacOS/JavaApplicationStub

    4. [appname]/Contents/Resources/[iconfile]

    5. [appname]/Contents/Resources/Java/[the actual jar file]




    • Ad 1) Info.plist is a special XML file. More about it later.

    • Ad 2) PkgInfo is a plain file with for sole content the chars "APPL????" in ascii

    • Ad 3) This file was copied from some Mac. Was found in the directory: /System/Library/Frameworks/JavaVM.framework/Versions/Current/Resources/MacOS/JavaApplicationStub

    • Ad 4) Some 128x128 px icon file, in the mac-icns format. CocoThumbX transformed my png well. This icon is referred of in the Info.plist

    • Ad 5) The core. I suppose further jar resources would go here, but i needed those not.






  • I'm packaging this on a linux machine, but the mac needs UTF-8. So iconv the only file that contains text (in my case):

    iconv --from-code=ISO-8859-1 --to-code=UTF-8 [appname]/Contents/Info.plist



  • I tried to zip this stuff, but it failed on file permissions, which weren't taken care of by zip, or at least this was what it looked like after unpacking it. However, for the app to be executed, the JavaApplicationStub needs its execute-bit to be set. Dead end.


    So i went the more complete way:

    					
    mkhybrid -hfs -hfs-unlock -hfs-volid [displayname] -o appfile.dmg -root [appname] [appname]

    aka Schilling-cdrecord, called from the dir above the directory structure described earlier. This gives a handy .dmg file the mac will mount when doubleclicked on, from which the user can drag the app whereever he wants.

    The -hfs-volid parameter is displayed as the dialog's title when the file is mounted. Had the problem i could not pass special chars here, but it wasn't tragic. The encoding of the filenames was prettily taken care of by mkisofs.

    hfs-unlock is there because the command seemed too short to me otherwise. I didn't notice an effect.

    The mkisofs 's manpage stated something about an icon i could put in there, being fancy somehow. Therefore i put a hidden .icns file in the image's root, after renaming it to "Icon
    " (yes, that's a carriage return. Let's shoot someone), as stated. But it didn't work, so i gave it up. Maybe something changed - the mkisofs's manpage ain't that new.




  • That's it. Makes a sweet ant script.
    You seemingly can make it more complicated than that, putting different parts for different "localizations", what you'd have to alter the directory structure for. But i needed it not, it's handled in the app itself.




Now comes the Info.plist part. Finding the syntax is quite easy. Google. What i weren't able to find were precise descriptions of possible keys and their effects.

Note that when the Info.plist file is interpreted, you have in your environment two special variables:

  • $APP_ROOT i'm not sure whether it points to the /Contents dir or to the one above

  • $JAVAROOT points to [appname]/Contents/Resources/Java/




So these are those i found:


  • [root of the plist]

    • CFBundleName
      Displayed under the icon on the desktop, as a tooltip in the dock, maybe elsewhere.

    • CFBundleVersion
      ?? Displayed in the "about", i believe.

    • CFBundleAllowMixedLocalizations
      ??

    • CFBundleGetInfoString
      Displayed in the "Get Information" window

    • CFBundleInfoDictionaryVersion
      ??

    • CFBundleExecutable
      The aforementioned "JavaApplicationStub" comes in here.

    • CFBundleDevelopmentRegion
      ?? possible values ? (default: "English")

    • CFBundlePackageType
      "APPL", the first four bytes of the "PkgInfo" file

    • CFBundleSignature
      "????", the four last bytes of the "PkgInfo" file. ???? means "mac does not know you". Damn, that hurts.

    • CFBundleIconFile
      The icon file in $APP_ROOT/Contents/Resources. Displayed here and there. Especially on the desktop.






  • Then there is a further dict for the key "Java". This one has the keys:


    • MainClass
      Like in the MANIFEST.MF

    • JVMVersion
      Java-version requirement. Google's full of this one. Looks like it makes some problems.

    • ClassPath
      I specify my jar here using $JAVAROOT



  • Then a key Properties listing another dict:

    • com.apple.macos.useScreenMenuBar
      Should make your JMenuBar being integrated in the Mac's sole menu-bar. Haven't used it though.

    • com.apple.smallTabs
      ?? Something to override that Human-Interface stuff of Apple's concerning tabbed panes

    • com.apple.mrj.application.live-resize
      ?? As opposed to dead-resize. More flexible, i guess.

    • com.apple.mrj.application.apple.menu.about.name
      Is being put in the menubar as the app's name. MUCH better than edu.xxx.snuff.Stiff.Main....

    • com.apple.macosx.AntiAliasedTextOn
      Fancy stuff

    • com.apple.macosx.AntiAliasedGraphicsOn
      Dito.

    • com.apple.mrj.application.growbox.intrudes
      Supposed to increase your window's size so that mac's resize box doesn't, as it is called, "intrude". However, using 1.4.2, i didn't notice a difference (it still intrudes).










I'd be glad if someone who has been working on this too could correct here and extend there.

FUTT.

   <<Less
About | Sitemap | Contact