I'm trying to display a html document from a JavaFX app. So I called
getHostServices().showDocument(filename);
But instead of showing the document in the default browser Firefox, the system brings up Chrome and displays the file in it. Chrome even prompt "Google Chrome isn't your default browser" and shows a big button to "Set as default".
How can I make sure the document is showing in the default browser?
I'm running Ubuntu 22.04, Firefox 125.0, Chrome 124.0.6367.60, openjdk 11.0.22, javafx-sdk-11.0.2 (from gluon)
According to the source code, the behavior of HostServices.showDocument() on Linux is simply going through a list of commands to open the url argument. With the version javafx-sdk-11.0.2 (downloaded from gluonhq), the list is {"google-chrome", "firefox", "opera", "konqueror", "mozilla"}, therefore, google chrome gets to open the file no matter which browser is the default on Linux.
On a later version of javafx (pointed out by James_D), the command "xdg-open" is added as the first element of the list. This should lead to the expected behavior of the showDocument method. Although I have yet to test it.