It's not a secret anymore!
The moose likes Beginning Java and the fly likes Open a HTML file 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 » Beginning Java
Bookmark "Open a HTML file" Watch "Open a HTML file" New topic

Open a HTML file

Bob Mazz

Joined: Mar 17, 2004
Posts: 5
Can anybody tell me some code to simply open a HTML file in a web browser please. Thankyou

Joined: Dec 03, 2003
Posts: 5
Using what u need 2 achive this? Be specific when u post the queries.
Ali Gohar
Ranch Hand

Joined: Mar 18, 2004
Posts: 572
just double click the html file it will automatically open in browser.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

You can use one of the java.lang.Runtime.exec() methods to launch the browser, if you know the path to the executable. Because Java is cross-platform, you can't just assume that it's IEXPLORE.EXE . You might ask the user to find the browser program in a file-selection box, then use Runtime.exec() to launch it.

[Jess in Action][AskingGoodQuestions]
Brian Pipa
Ranch Hand

Joined: Sep 29, 2003
Posts: 299
This definitely needs to be in an FAQ somewhere - not that anyone would read it though
Use BrowserLauncher -
Works great.

My Java Freeware:<br />MACCC - <a href="" target="_blank" rel="nofollow"></a><br />Nator - <a href="" target="_blank" rel="nofollow"></a>
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Originally posted by Brian Pipa:
This definitely needs to be in an FAQ somewhere

I agree. This topic has come up a few times.
Don't forget that you have the ability to add it to the FAQ. It's a wiki after all.
I agree. Here's the link:
subject: Open a HTML file
It's not a secret anymore!