So, I’m writing a tiny little application that sits in your status bar and pops up occasional reminder messages in the corner of your desktop. It uses the Java 6 desktop integration stuff. It’s not very exciting – just fun and moderately useful.
I originally wrote this for Victoria with a set of hardcoded messages, so it only needed to run on windows. It worked really well, so I thought I’d turn it into a proper application – it should only be a few hours of coding to do so.
Especially, I thought, as it should run nicely cross platform.
Ha ha. Ha.
First off, Macs are ruled out – no functioning Java 6 yet. I took a brief look at using jdic instead, but it turns out that doesn’t support macs either. Argh. So, we’re stuck with windows and linux. Ho hum.
Yeah, linux? Not so much.
First off, Swing *never* works properly under linux. As far as writing cross platform GUIs, “Write once, run anywhere” is a blatant and utter lie. If you’re using Gnome or KDE with their standard window managers, it will just about limp by. If you’re using anything else, good luck.
Anyway, I use xmonad. However I use xmonad with gnome (at least on my laptop), and this is just a status bar feature, so given that I still have the gnome status bar I was optimistic.
Nope. Looks like Swing checks the window manager name, not the availability of the status bar. It’s really great the way the Swing/AWT developers actually understand the environment they’re developing for, isn’t it? On a related note, the resulting toolbar icon looks *really bad* even when I run it under normal gnome. That’s probably just a scaling and transparency issue though. I imagine I can sort it out if I try hard enough.
I have to say, despite this the desktop integration stuff is moderately nice. It’s a great way of writing once and running anywhere that has windows and the latest version of Java installed.
Sigh.
Yeah, Java sucks under Linux. I’m not sure how Azureus side steps this, but most simple Java applications I run will only run on one of my two displays. I’m using a non-standard multi-headed setup, where one display has DISPLAY=:0.1 and the other :0.0, which Java doesn’t like. Hilariously, it goes ArrayIndexOutOfBoundsException: 1. Looks like they need to do some coding…
Azureus sidesteps it by using SWT rather than Swing.
And yes, I have a lot of annoying issues with java and multiple monitors. Even under windows its behaviour is not perfect, though it’s much better.
Yeah, a better description for Java is “write once, run away.“
If you’re getting false from SystemTray.isSupported(), it might be because of a bug in Java6. I had the same problem (xmonad and a gnome-panel), and using an early release of jdk7 fixed it.
john:
Yeah, but the program is actually written in Scala. :-)
recht:
Thanks.That’s good to know. Are you aware of a more immediate workaround?
It was really way too optimistic of me to expect this to work with xmonad anywhere in sight anyway. I’ve had nothing but problems with Swing + XMonad. I think it’s time to switch to Jambi. :-)
Unfortunately there seem to be no other solutions than to wait for java7 or java6 update n, which should also fix the problem. However, I don’t quite recognize your xmonad problems. The only problem I’ve had is that some windows are blank when they are displayed. This can be fixed either by setting AWT_TOOLKIT=MToolkit or using the setWMName “LG3D” hook.
Swing has a number of strange bugs with components (particularly modal ones) losing focus and finding it impossible to receive keyboard events afterwards. XMonad seems to aggravate this greatly. It causes both IDEA and Bloglines to be unusable for example.
Not only Java sucks on Linux. Anybody suffers from all those hacking around window manager bugs on X11, there are just too many of them, most don’t follow established protocols (or don’t do it right/correct).
Just look at focus, clipboard and input method support, add in some screensaver and xft support and your in for a real mess.
As David pointed out, SWT works on Linux. I have an SWT tray notifier that works fine on Linux and Windows.
Note you need SWT version 3.3 to get a tray notifier on mac.
That should work in theory but I haven’t upgraded yet…