Tight integration of Java apps in OS X

Discussion in 'Mac Programming' started by radebe, Sep 27, 2008.

  1. radebe macrumors newbie

    Mar 14, 2008
    Norwich, UK
    I'm taking on a project which has already started development as a Windows XP application written in Java. It's my job to port it over to the Mac, whilst keeping it easy to continue to develop on multiple platforms. The thing is, I generally don't like running Java applications on my Mac myself, because they just don't look like they belong. Everything from the interface to the menus being in the wrong place, and the general look and feel. I'd love to be able to improve on this, to the point where the end user would have no clue that the application was written in Java. How would I go about this? I've looked into the Java-Cocoa API, but it seems to be depreciated now. Any help is greatly appreciated.
  2. AlmostThere macrumors 6502a

    You could try and use something like Quaqua as LAF (http://www.randelshofer.ch/quaqua/index.html). It's not going to give you 100% native appearance but it does a pretty good job where it can.

    The cost of using a cross platform toolkit is that you end up with the lowest common denominator functionality, so you will also need to try and keep the features you use to those that are well implemented.

    (mini-rant, sorry)
    The other thing is to realise that a great app is a great app regardless of whether it fits in perfectly with everything else. I used to feel in a similar way but now I wouldn't trade IntelliJ for Xcode, ever. However nice Xcode looks or however well it 'fits' into OS X, it is simply erm, Eclipsed in terms of ease of use and functionality by other Java IDEs (despite their occasional quirks and imperfect integration).

    Depending on your end users, they might not know the difference anyway. What might be obvious through your developer's eyes is not always apparent from the point of view of the end user (who may also be in the function over form camp).

    Finally, it might not be an immediate option, but I *think* (and would need to google to confirm this) that SWT might be upgraded to work on top of Cocoa, although that might be some time off.

    (edit) if your menus are in the wrong place, make sure you are running, IIRC, with -Dapple.laf.useScreenMenuBar
  3. iSee macrumors 68040


    Oct 25, 2004
    Take the app as it runs on OS X now and review it, top to bottom, against the OS X human interface guidelines and identify all the discrepancies. You may be able to get most of the way to your ideal just by working on "cosmetic" issues.

    It's a good place to start because most of these kinds of things are easy to deal with at a code level and have a big impact on the user's experience.
  4. MacRumors Guy macrumors member

    Sep 17, 2008
    You can always wrap the business logic through JNI and do the interface in Cocoa
  5. wrldwzrd89 macrumors G5


    Jun 6, 2003
    Solon, OH
    Quaqua is a big help, but there's more you can do.

    Make Your Swing App Go Native

    I use that extensively for my Java applications. It makes them much better Mac OS X citizens.
  6. cube macrumors Pentium

    May 10, 2004
    That's nice, but how do you make a native-looking Java Web Start application?

    It seems you have to detect the platform from the User Agent string and give a different JNLP file just for Apple, with a tweaked application-desc.
  7. radebe thread starter macrumors newbie

    Mar 14, 2008
    Norwich, UK
    Can anyone advise me on whether or not this would be a good method? To be honest, seeing what people have already done with Quaqua doesn't seem to suggest that it'll be able to produce the integration I'd really like. Does anyone know what Firefox does in version 3? Obviously it's not Java - but does it have a native Cocoa interface for the toolbar etc. or is it just faked with themes? There are a few things that suggest to me that it's fake, but it's fairly convincing until you look really closely.
  8. whitehexagon macrumors regular


    May 12, 2007
    I'd probably go for SWT. That should give you something native looking on OSX, and still allow you to keep your native windows look and feel.


    PS It's what eclipse currently uses to look native on each platform.
  9. MacRumors Guy macrumors member

    Sep 17, 2008
    It's not very easy to wrap the code through JNI.

    Firefox uses XUL in every system but uses some cocoa elements. The core is written in c++ mostly so it's not very hard to get it to work with objective-C.

Share This Page