Opening browser from Java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • latheef
    New Member
    • Jun 2006
    • 5

    Opening browser from Java

    Hi,

    I want to open a browser and place it and size it as I wish,when user selects an option from the menu written in java.
    I tried passing command line argument rundll32 url.dll,FilePro tocolHandler<ur l>
    in windows 2000 it works fine.But in Xp it doesn't work.Can anyone help me out .

    Is there any other way of invoking browser from java application or applet to open a browser which should be positioned and resized as we want(no jdic browser).?

    Latheef
  • tweedie
    New Member
    • Jul 2006
    • 1

    #2
    Oh I remember this one from one of my project I was doing that might do the trick. you basically need to pass ? at the end of the url string if the OSVersion is greater then 5.0

    Code:
    //// url variable contains the url string address ie http://www.bbc.co.uk
    
    // If in win2k and http, the cmd must end with a "?"!
    float OSVersion = Float.parseFloat(System.getProperty("os.version"));
    if (OSVersion >= 5.0f && url.toLowerCase().startsWith("http")) {
        url = url + "?";
    }
    
    String cmd = "rundll32 url.dll,FileProtocolHandler " + url + "";
    Process r = Runtime.getRuntime().exec(cmd);
    As for the position of the browser window -- sorry, haven't a clue about that.

    Comment

    • latheef
      New Member
      • Jun 2006
      • 5

      #3
      Thanks for the reply.
      What I pass in cmd is:
      javascript:wind ow.resizeTo(550 ,602);window.mo veTo(550,138);l ocation.href="h ttp://yahoo.com"
      But it does n't work in windows XP-sp2.This one works in 2000.
      Any idea!

      Comment

      Working...