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("http://www.sun.com"));
}
}
} catch (Exception e) {
e.printStackTrace();
}
Everything seams to be fine. But when you run it on Fedora 6 on KDE it ends up with
java.io.IOException: Failed to show URI:http://www.sun.com
at sun.awt.X11.XDesktopPeer.launch(XDesktopPeer.java:75)
at sun.awt.X11.XDesktopPeer.browse(XDesktopPeer.java:64)
at java.awt.Desktop.browse(Desktop.java:368)
at Main.main(Main.java:12)
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:
- Why KDE is simply ignored?
- Is it so difficult to add support even for Gnome that works?