AWT has a method that allows to launch the default browser to display a URI. It doesn't work under GNU Linux with KDE. There is not yet any alternative to this method in NEWT.
The method org.lwjgl.Sys.openURL(String URL) of LWJGL 2 is a good source of inspiration:
It uses Java Webstart first and it has several platform-dependent fallbacks. I suggest to modify them a little bit:
- $BROWSER, "xdg-open", "gnome-open", "kde-open", "x-www-browser" or "sensible-browser" under GNU Linux
- "open" under Mac OS X (instead of com.apple.eio.FileManager.openURL())
- "rundll32 url.dll,FileProtocolHandler" under Microsoft Windows
- new Intent(Intent.ACTION_VIEW, Uri.parse(String URL)) and startActivity(intent) under Android
XFCE uses exo-open, it should be called if the xdg-utils package isn't installed.
Maybe "cmd /c start" can be used under Windows:
Why shall this feature be part of NEWT?
While I see the short-cut benefits of kicking off a native browser,
I would prefer seeing html/css rendering via OpenGL/Graph
purely performed within Java.
Further, launching an external browser might also be considered a security
risk, since the launch requires privileged mode and the browser itself
cannot be considered secure.
If there are no others liking to introduce this features,
I would like to mark this entry invalid, while open a new bug report
introducing the need for a Java browser using OpenGL/Graph.
This kind of feature is commonly used by some major free softwares, for example Notepad++ and TortoiseGit. Numerous Android applications use it too in order to redirect the end users to a website.
Is there a way of providing a safe implementation of this feature? I can implement it (I need it for my own native update system) but I don't see why it wouldn't be part of NEWT.
Creating a Java web browser for such a rudimentary need is like using a nuclear bomb to kill a butterfly to me.
I tried to use JCEF, the build files were half-broken, the source code contained a very few compile errors and there were so much problems that I gave up. It worked somehow in very simple cases but I didn't find a way of shutting it down cleanly.
I tried gngr too but it doesn't have enough features, it's a very poor web browser.
I ended up by using The DJ Project "Native Swing". It seems to launch a native browser embedded into a Swing component:
If you don't need to embed a browser in your software, my first suggestions will be enough.
Sven is right, opening a website in the default web browser doesn't need to be a part of NEWT even though it's an AWT feature whereas displaying HTML/CSS content within JOGL with the Graph API would make sense.