Hi Emmanuel,

Am 04.04.2017 um 10:52 schrieb Emmanuel Bourg:
> Excellent question, this needs some testing with various desktop
> environments.

I wrote a short test script and run it under Stretch and Jessie chroots,
right after

(jessie)oles@donar:~$ sudo apt install default-jre

-------------------------------8<----------------------------------
import java.awt.Desktop;
import java.net.URI;

class DesktopTest {
    public static void main(String[] args) throws Exception {
        System.out.println("isDesktopSupported()="
                           + Desktop.isDesktopSupported());
        Desktop d = Desktop.getDesktop();
        System.out.println("Desktop=" + d);
        System.out.println("Browse supported="
                           + d.isSupported(Desktop.Action.BROWSE));
        d.browse(new URI("https://www.debian.org";));
    }
}
-------------------------------8<----------------------------------

with the following output:

(jessie)oles@donar:~$ java Desktop
isDesktopSupported()=true
Desktop=java.awt.Desktop@669e9a07
Browse supported=true
Exception in thread "main" java.io.IOException: Failed to show
URI:https://www.debian.org
        at sun.awt.X11.XDesktopPeer.launch(XDesktopPeer.java:114)
        at sun.awt.X11.XDesktopPeer.browse(XDesktopPeer.java:98)
        at java.awt.Desktop.browse(Desktop.java:386)
        at Desktop.main(Desktop.java:9)

So, on a default (not headless) Java installation, Java claims to both
isDesktopSupported() and isSupported(Desktop.Action.BROWSE).

The exception may be due to the fact that my Browser was running outside
of the schroot, that the dbus was not started ("xdg-open" shows this as
error), or that some other required component is not there.

Desktop#browse() calls the native function gnome_url_show() in
XDesktopPeer.java:

https://developer.gnome.org/libgnome/stable/libgnome-gnome-url.html

Best regards

Ole

Reply via email to