aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Open a URL from java swing application or java standalone program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Open a URL from java swing application or java standalone program" Watch "Open a URL from java swing application or java standalone program" New topic
Author

Open a URL from java swing application or java standalone program

Susmitha Metlapalli
Ranch Hand

Joined: May 16, 2007
Posts: 44
Hi,

Can we open a URL from any standalone java program?

Is there any other solution other than Runtime.getRuntime().exec("cmd.exe /C start http://yahoo.com");?

Thanks in advance,
Susmitha.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10266
    
    8

If you are using 1.6 check out the Desktop API.
If not, search the forums. This question comes up quite a lot.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1


There is URLConnection class available, that will help you to connect URL from any Java application.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Susmitha Metlapalli
Ranch Hand

Joined: May 16, 2007
Posts: 44
I am using JDK1.4.

I have to open a URL from standalone java program.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10266
    
    8

Can you elaborate on "open a URL from standalone java program."?

If you want to display the URL page in a Java application, you need to use the JEditorPane or something similar.
If you want to open the URL page using the system's registered application, like a browser, search the forum. Like I said this question comes up quite frequently.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41571
    
  54
If you're talking about opening HTTP URLs in a web browser, check out BareBonesBrowserLauncher.

If you're talking about an embedded browser in a Java application, have a look at Lobo (on SourceForge) - it's much better than JEditorPane.


Ping & DNS - my free Android networking tools app
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Open a URL from java swing application or java standalone program