This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Java in General and the fly likes How to execute a browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to execute a browser" Watch "How to execute a browser" New topic

How to execute a browser

Shane Roylance
Ranch Hand

Joined: Aug 29, 2001
Posts: 72
I am not trying to kill the browser, but I am trying to execute a browser from my java application. The only way I have found so far to do this is to use And while this will work, I was hoping for something a little more generic that would execute the default browser (not a hard coded one), and display the given URL.
So is there another way???
Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
I believe you can do it like this.
using this website
use this:

Note: I have only proven this to be correct, I have not actually tested it.

Jason R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="" target="_blank" rel="nofollow"></a>
Rob Ross

Joined: Jan 07, 2002
Posts: 2205
Actually the simplest way is :
This will use the default browser.
[ May 28, 2002: Message edited by: Rob Ross ]

SCJP 1.4
Shane Roylance
Ranch Hand

Joined: Aug 29, 2001
Posts: 72
Thanks for the suggestions Jason and Rob, unfortunately they are not working for me. I get an IOException from the exec command that says "CreateProcess: <command entered> error=2". I haven't been able to find out exactly what this means, but I assume it means I can't figure out what you are trying to exec. It happens with just the HTTP string or with the start preceding it.
That brings me to another question would a Runtime.exec() command be more comparable to the dos command prompt or the Start->Run dialog?
Shane Roylance
Ranch Hand

Joined: Aug 29, 2001
Posts: 72
Does anyone have any ideas as to why the previous suggestions were not working for me? I am developing and running on Win2K.
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
JConfig claims to be able to launch web browsers.
I agree. Here's the link:
subject: How to execute a browser
It's not a secret anymore!