Monday, August 20, 2012

open default web browser using java in widows


This method will open your default web browser in windows and open the url "www.google.lk"

String url="www.google.lk";  //add required url here
 try {
             String osName = System.getProperty("os.name");
                    if (osName.startsWith("Windows"))
                           Runtime.getRuntime().exec(
                                "rundll32 url.dll,FileProtocolHandler " + url);
} catch (Exception ex) {
}

0 comments:

Post a Comment