Opening an URL from java

后端 未结 3 748
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-03 16:16

we\'re writing an open-source jdbc driver for bigquery, and ran into the following problem:

We want to authorize our driver with Oauth 2 as an installed application.

3条回答
  •  感动是毒
    2021-01-03 16:47

    Basically sounds good but here is another way if you want to open using specific browser (if more than one browser in the system)

    String url = "http:/devmain.blogspot.com/";
    String[] browsers = { "firefox", "opera", "mozilla", "netscape" }; // common browser names
    String browser = null;
    for (int count = 0; count < browsers.length && browser == null; count++)
      if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] }).waitFor() == 0)
        browser = browsers[count]; // have found a browser
    Runtime.getRuntime().exec(new String[] { browser, url }) // open using a browser
    

    More details here: http://devmain.blogspot.com/2013/10/java-how-to-open-url-in-browser.html

提交回复
热议问题