Monday, June 25, 2007

Troubles with java.awt.Desktop browse() method

New Desktop features were added in Java 6. One of those features is browse(URI uri) method, which launches the user-default browser to show a specified URI.
So, it is quite easy to show some web-page to user: check if desktop is supported, then check if BROWSE action is supported and call browse() method. Here is some code chunk:

try {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Desktop.Action.BROWSE)) {
desktop.browse(new URI(""));
} catch (Exception e) {

Everything seams to be fine. But when you run it on Fedora 6 on KDE it ends up with Failed to show URI:
at sun.awt.X11.XDesktopPeer.launch(
at sun.awt.X11.XDesktopPeer.browse(
at java.awt.Desktop.browse(
at Main.main(

So, you go to Sun's bug database and start searching what is going on. And here it is: bug 6486393 (Need a KDE support in java.awt.Desktop class). So, it turns out that Desktop API was developed to support Windows and Gnome only. Upps.
OK, you are switching to Gnome on the same Fedora 6, run the example again and... you have the same exception. It does not work.
Two question are arising to Sun's engineers:
  1. Why KDE is simply ignored?
  2. Is it so difficult to add support even for Gnome that works?

Monday, June 18, 2007

The Pain With Java System Tray On KDE Desktop

System Tray came to us with Java 6. It is great feature we were waiting for a long time. Its functionality was very limited. Nevertheless many java developers were happy (including me).
Unfortunately, this new functionality came with problems. Namely one BIG problem. System tray does not work on KDE desktop. Bug with ID 6448876. Yes, it still exists. The really bad thing with the bag is that it looks like it WONT BE FIXED before Java 7. If you look at the user comments to the bag, you can see how many developers are frustrated with it. But it is marked as "closed", so it is ignored by Sun engineers.
I clearly realize MS Windows is OS of overwhelming majority of PC abound the globe. But there are also a lots of PC under Linux platform. And KDE is very popular desktop among Linux users. For those users Java system tray does not work. And wont work in the nearest future.
The good news is that Sun JRE is not the only one. There are also BEA JRockit and IBM IBM Early Release Program SDK 6. The latter is some kind of beta and is not available for MS Windows. On BOTH of them system tray works. And both of them have two problems:
  • they are rarely installed on regular Linux user PCs;
  • they have 32/64 bit CPU problem (which Sun Java does not have).
The 32/64 but CPU problem (my term :) ) is that there are a lots of 32 bit Linux installations on 64 bit PCs. You can't install 64 bit Java on such machines. 32 bit Java is the only choice. Both BEA and IBM 32 bit Java's don't work well on such machines.
The conclusion is: if you have a big desktop application which needs system tray functionality, you have a big headache with making it run correctly on KDE desktop.

Saturday, June 16, 2007

Browser support for jar protocol

I've just discovered that jar protocol (jar:!/{entry}) is rarely supported by web browsers.
For testing I've used the link found accidentally on the web: jar:!/index.html.
MS IExplorer failed to open it.
The same was with Opera.
In fact the only browser that manager to open it was Firefox.
I also tried Konqueror. Just for fun. As you can guess, it don't support jar protocol too.