title: Opening an URL from java
body: <p>we're writing an open-source jdbc driver for bigquery, and ran into the following problem:</p>
  
  <p>We want to authorize our driver with Oauth 2 as an installed application. On windows xp, windows 7 x64, windows 7 x64 + RDP it works fine. But on the testbench which is a windows server 2008 R2 + RDP it fails.</p>
  
  <p>Basically, we open a web browser, he logs in, we catch the reply, and authenticate the user.</p>
  
  <p>Here's the code for the url opening:</p>
  
  <pre><code>    private static void browse(String url) {
      // first try the Java Desktop
      logger.debug("First try the Java Desktop");
      if (Desktop.isDesktopSupported()) {
          Desktop desktop = Desktop.getDesktop();
          if (desktop.isSupported(Action.BROWSE))
              try {
                  desktop.browse(URI.create(url));
                  return;
              } catch (IOException e) {
                  // handled below
              }
      }
      // Next try rundll32 (only works on Windows)
      logger.debug("Try the rundll32");
      try {
          Runtime.getRuntime().exec(
                  "rundll32 url.dll,FileProtocolHandler " + url);
          return;
      } catch (IOException e) {
          // handled below
      }
      // Next try browsers
      logger.debug("Try with browsers");
      BareBonesBrowserLaunch.openURL(url);
  }
  </code></pre>
  
  <p>What i figured out is: BareBonesBrowserLaunch doesn't open the link, nor does the FileProtocolHandler.</p>
  
  <p>The URL lenght is a little bit under 250character.</p>
  
  <p>Any assistance would be appreciated!</p>