JDK BUG: Desktop.browse() doesn't work in snap environment but xdg-open works just fine

This commit is contained in:
Reinhard Pointner 2018-06-21 03:41:48 +07:00
parent ab32d2feeb
commit f2051e835b
1 changed files with 7 additions and 1 deletions

View File

@ -79,7 +79,13 @@ public final class SwingUI {
public static void openURI(String uri) {
try {
Desktop.getDesktop().browse(URI.create(uri));
if (Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(URI.create(uri));
} else {
// JDK BUG: Desktop.browse() doesn't work in snap environment but xdg-open works just fine
ProcessBuilder p = new ProcessBuilder("xdg-open", uri);
p.inheritIO().start();
}
} catch (Exception e) {
debug.log(Level.SEVERE, "Failed to open URI: " + uri, e);
}