Desktop browse does not work in java for Ubuntu [duplicate]
Asked Answered
L

2

7
desktop = Desktop.getDesktop().browse(uri);

The above code does not work in the Ubuntu OS. If I execute this code, then my application gets struck and hangs for a while and during that time I cannot stop the running application in java console. The only way am able to close that application is by FORCE QUIT.

Ludwog answered 21/2, 2014 at 11:38 Comment(3)
Does Desktop.isDesktopSupported() return true?Mainland
And what about: Desktop.isSupported(Action.BROWSE)?Mainland
Desktop.isDesktopSupported() Returning True and same problem existing by using only Desktop.isSupported(Action.BROWSE) @MainlandLudwog
B
2

There are several threads on this issue. I have the same hangs on Ubuntu 16.04. I have posted here the workaround that I'm using: Desktop.getDesktop().browse Hangs

Brach answered 13/3, 2019 at 9:42 Comment(0)
E
1

This API depends on the gnome library, you need to have gnome libraries installed for this to work.

Something similar sudo apt-get install libgnome should do the trick i think (do not have my ubuntu desktop at hand to check the package name, try apt-cache search libgnome to find the real name if this does not work).

Note : you should specify which JVM you are using, I assume it's oracle JVM.

You could also give browserlaunch2 a try, yet it's rather old and I've never used it myself. As written on it's website it is meant to open the default browser on the supplied url :

BrowserLauncher2, a continuation of the BrowserLauncher project, is a library that facilitates opening a browser from a Java application and directing the browser to a supplied url. In most cases the browser opened will be the user's default browser.

BrowserLauncher launcher = new BrowserLauncher();
launcher.openURLinBrowser("http://www.google.com");

As BrowserLauncher2 is open source, you could also have a look at how it detects the default browser.

Erythrocyte answered 21/2, 2014 at 12:25 Comment(4)
yes am using Oracle JVM Java 8 b-129 which is the latest versionLudwog
Have you tried to install the lib ? It should work with it installedErythrocyte
yes Still it does not Working.. is there anyother suggestionLudwog
Sorry, I don't know why it hangs then. You could try browserlaunch2.Erythrocyte

© 2022 - 2024 — McMap. All rights reserved.