File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes launching  URL in new browser window 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 » Java in General
Bookmark "launching  URL in new browser window" Watch "launching  URL in new browser window" New topic
Author

launching URL in new browser window

Medha kamat
Greenhorn

Joined: Aug 22, 2002
Posts: 21
Hi
Can anybody out there tell me how to open URL in new browser window from java application?
I am using Runtime.getRuntime().exec with rundll32 but this opens a URL in existing window.
Thanks
Medha Kamat
Phil Chuang
Ranch Hand

Joined: Feb 15, 2003
Posts: 251
You'll probably find it a lot easier to open a new window on the client side of things (IE use HTML to do it instead of your app)
In the A HREF link, add the param TARGET="_blank" and that will open a new window, and have the HREF point to the servlet or whichever you wanted in a new window.
Medha kamat
Greenhorn

Joined: Aug 22, 2002
Posts: 21
HI
Thanks for the reply.
Well i know i can open a new window on client side.I know javascript very well.But what i am tying to do here is very different.
I have swing component (not an applet).When user clicks on menu item user should get a new browser window.Java objects create HTML which should be opened in this window.So i want this to happen from within application.
Problem with Runtime.getRuntime().exec is it opens a browser window if none is open.But if browser window is open then it tries to display my HTML in a opened browser window.That not a good scenario as user might be browsing some important information from my system and it would get lost.
What i want is this HTML should always opened in a new window.
Any ideas or workaround...???Any other solution?

Thanks
Medha
Phil Chuang
Ranch Hand

Joined: Feb 15, 2003
Posts: 251
I think this is an IE issue (i'm assuming you're using IE).
Open IE, tools->internet options->advanced tab
under the browsing category,
uncheck the box that says "reuse windows for launching shortcuts" , and then try your program again.
ali rafiq
Ranch Hand

Joined: Jan 09, 2003
Posts: 75
if u want to some beautyfull is here i hope u like with soucre code


if u learn to break the rock .. next day u will be looking to Mountain.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
When you exec to RunDLL32 with an HTML file argument, it works exactly as if you had clicked on the file in Windows Explorer, or even typed the name in a command window. URL arguments work the same way.
You could instead exec the Internet Explorer executable which should always open a new browser. Mine is at "C:\Program Files\Internet Explorer\IEXPLORE.EXE" Add the URL as an argument (I think).
This is trickier if you want it to run on other people's PCs - they may have different versions of IE in different locations, or Netscape or Opera or some other browser. Can you get the default browser from the registry and exec that?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: launching URL in new browser window
 
Similar Threads
IE shows a horrifying gap!
Links in Applets
Applets form in webpage
close browser, open new window
Issue with copy pasting the URL