is it possible to launch default web browser from java program?

i would like to make my program able to launch a web browser for example mozilla with some address url.
it can be made using Proccess.exec, but i was thinking is it possible to do it in another way to launch DEFAULT user browser and also it should work on all platforms, of course i am talking about java programs not applets

If you were using an Applet, it would be easy. (Check the Applet methods for more info.) Otherwise your best option is JDIC. Webstart also provide the “showDocument()” method in javax.jnlp.BasicService.

jdic is very intresting, i also found intresting article about it here:
http://www-128.ibm.com/developerworks/java/library/j-jdic/
but i was thinking is it poosible to make it withut native libs, but this is also good, thanx jbanes

and there is also jrex : http://jrex.mozdev.org/docs.html

Glad to be of service. Just so you know, there’s also the Browser Launcher library that’s (supposedly) 100% Java. JDIC, OTOH, is slowly moving into the Java core, starting with release 1.6. So it’s something of a toss-up as to which option is “better”. Good luck!

it is easy to do without native libs.

Check the platform and run the command line that makes sense for the OS you are on.

Mac OS you can use "open "
Windows has a couple options, "cmd /C start /B " works,and a more direct way, (I think this works) is "rundll32 SHELL32.DLL,ShellExec_RunDLL "
Linux… is more troublesome :slight_smile:

you are the best guys, browser launcher is that what i was looking for, but it is quite old and some functions especially for macintosh are not working , but there is a new implementation of launchbrowser here which is the best and free: http://browserlaunch2.sourceforge.net
and supports probably all systems:

Linux (2.4.x or higher) FireFox, Mozilla, Netscape, Konqueror, Opera Supported Supported
Mac OS X (10.2 or higher) Supported
SunOS Mozilla, Firefox, Netscape Supported Supported The default browser is invoked using the sdtwebclient command.
Windows 2000 Mozilla, Firefox, IE Supported Supported.
Windows 2003 Mozilla, Firefox, IE Supported Supported.
Windows 98 Mozilla, Firefox, IE Supported Supported.
Windows NT Mozilla, Firefox, IE Supported Supported.
Windows XP Mozilla, Firefox, IE Supported Supported.

and some intresting discussion can be found here: http://www.codecomments.com/archive245-2005-12-724947.html

also you may be intrested in this project : http://multivalent.sourceforge.net/

again thanx guys

Mustang provides an API to launch the default browser and other tools such as email client. Check on javasoft.com for the article on the API. Of course you have to stick to Java 6, which may have a major impact on the deployment of your app.

browser email client in mustang cool, more can be found here:
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/mustang/desktop_api/

thanx TheAnalogKid