Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Open a URL from java swing application or java standalone program

 
Susmitha Metlapalli
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using 1.6 check out the Desktop API.
If not, search the forums. This question comes up quite a lot.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There is URLConnection class available, that will help you to connect URL from any Java application.
 
Susmitha Metlapalli
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using JDK1.4.

I have to open a URL from standalone java program.
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic