Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

launching URL in new browser window

 
Medha kamat
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if u want to some beautyfull is here i hope u like with soucre code
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic