I'm trying to open a link in the default browser from Java. I do not want to create a simple web browser, I want to use an existing one. People have suggested to use the following:
Desktop.getDesktop().browse(new URI("http://www.targetsite.com"));
However, this simply hangs upon calling browse
, and I end up having to force quit.
I saw a suggestion to run the following, to find out if Desktop and desktop.browse should be working on my system:
if (Desktop.isDesktopSupported()) {
System.out.println("Desktop IS supported on this platform ");
if (Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
System.out.println("Action BROWSE IS supported on this platform ");
} else {
System.out.println("Action BROWSE ISN'T supported on this platform ");
}
} else {
System.out.println("Desktop ISN'T supported on this platform ");
}
which gave the output:
Desktop IS supported on this platform
Action BROWSE IS supported on this platform
What can I do to fix, or work around this?
Using Java 1.8.0_73