File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to execute a browser" Watch "How to execute a browser" New topic
Author

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
http://www.reallifecomics.com/d/20000518.html
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="http://alia.iwarp.com" target="_blank" rel="nofollow">http://alia.iwarp.com</a>
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
Actually the simplest way is :
Runtime.getRuntime().exec("start http://www.reallifecomics.com");
This will use the default browser.
[ May 28, 2002: Message edited by: Rob Ross ]

Rob
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to execute a browser
 
Similar Threads
Problem in JSF
problem with timer object in applet
Mouse clicks combination
Servlet reporting progress
applet