File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 45
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: 10519
    
    9

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: 45
I am using JDK1.4.

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

Joined: Jul 26, 2007
Posts: 10519
    
    9

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: 42599
    
  65
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Open a URL from java swing application or java standalone program