PDA

View Full Version : Tight integration of Java apps in OS X




radebe
Sep 27, 2008, 07:32 AM
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.
Thanks,
Luke



AlmostThere
Sep 27, 2008, 08:07 AM
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

iSee
Sep 27, 2008, 08:48 AM
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.

MacRumors Guy
Sep 27, 2008, 11:27 AM
You can always wrap the business logic through JNI and do the interface in Cocoa

wrldwzrd89
Sep 27, 2008, 03:05 PM
Quaqua is a big help, but there's more you can do.

Make Your Swing App Go Native (http://today.java.net/pub/a/today/2003/12/08/swing.html)

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

cube
Sep 27, 2008, 06:27 PM
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.

radebe
Sep 29, 2008, 07:14 AM
You can always wrap the business logic through JNI and do the interface in Cocoa
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.

whitehexagon
Sep 29, 2008, 07:20 AM
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.

http://en.wikipedia.org/wiki/Standard_Widget_Toolkit

PS It's what eclipse currently uses to look native on each platform.

MacRumors Guy
Sep 29, 2008, 09:57 AM
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.

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.