title: Open URL in existing browser/tab in java
body: <p>With the following Code I managed to open an URL with my external Browser (in my case - Firefox). Every URL open action creates a new tab and over time I have hundreds of tabs, which I want to prevent. I use this for a tool to visually check some dates in a webpage and when pressing next, it should show the next page in the same tab.</p>
  
  <p>How do i achieve this ?</p>
  
  <p>Code:</p>
  
  <pre><code>public static void openWebpage(URL url) {
      try {
          openWebpage(url.toURI());
      } catch (URISyntaxException e) {
          e.printStackTrace();
      }
  }
  
  public static void openWebpage(URI uri) {
      Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
      if (desktop != null &amp;&amp; desktop.isSupported(Desktop.Action.BROWSE)) {
          try {
              desktop.browse(uri);
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>