Opening a URL from JAVA swing application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arivazhaganit
    New Member
    • Oct 2006
    • 9

    #1

    Opening a URL from JAVA swing application

    hi..
    I'm developing an application in java swing , in that If I click a button , that event should open a file like( http://www.google.co.i n) in a browser or in mycomputer..... Plz help me
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by arivazhaganit
    hi..
    I'm developing an application in java swing , in that If I click a button , that event should open a file like( http://www.google.co.i n) in a browser or in mycomputer..... Plz help me
    You can use Runtime.exec

    Code:
    String browserPath = "C:/Program Files/Internet Explorer/IEXPLORE.EXE"; //Use your browser path
          String url = "www.sun.com";
          try {
               String[] b = {browserPath, url};
               Runtime.getRuntime().exec(b);
           }
           catch (Exception exc) {
    	exc.printStackTrace();
           }

    Comment

    • arivazhaganit
      New Member
      • Oct 2006
      • 9

      #3
      hi..

      thanks for your information , if I'm running my application to someother system , how can let it know the path of IExplore ...?? should I give the new URL always while running on other system??
      Any other idea to get the path???

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by arivazhaganit
        hi..

        thanks for your information , if I'm running my application to someother system , how can let it know the path of IExplore ...?? should I give the new URL always while running on other system??
        Any other idea to get the path???
        Here is a discussion on this.

        Maybe you could also look at this

        Comment

        • arivazhaganit
          New Member
          • Oct 2006
          • 9

          #5
          is there any possible through Java.net.URL ????

          Comment

          Working...