wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes open Browser from java application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "open Browser from java application" Watch "open Browser from java application" New topic
Author

open Browser from java application

YuenLian Wu
Ranch Hand

Joined: Nov 16, 2005
Posts: 73
Dear all,

I am new to Java, and I hope you can answer my stupid question. I want to open a browser with URL specified from a Java application window(GUI with JFC/Swing). How can I implement that ? e.g There is a JButton @ the GUI form, and once I click the button, then the IE will be opened and forward to the site that I specified @ the GUI form.

Please help me out

Myraid Thanks

Transistor
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Look at the java.lang.Runtime class. But keep in mind that not everyone uses (or even has) Microsoft IE.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Hmmm... Apparently, Java 6 will introduce a new Desktop API that will launch the default browser or email client. (Nice!)

In the meantime, I just found this code for a decent platform-independent approach. I haven't tried it myself, so let us know how this works if you use it.

(PS: I found these by searching on "java default browser".)
[ May 21, 2006: Message edited by: marc weber ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41177
    
  45
The class Marc mentioned could be combined with this one to get something decent, I think.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: open Browser from java application
 
Similar Threads
How to open an PDF file from Java Application
JWS - A Good Way To Demo Apps
Can you start an application on the server by calling a servlet
Open a Browser
Open browser when u click a button