title: Execute JavaScript on web browser by Java
body: <p>Is there any way to click on particular links on web browser or run some javaScripts after opening a browser using Java?  </p>
  
  <p>I have used this code to launch the browser. But how can I run some JS on this web browser or click any links on it by using JAVA ?</p>
  
  <pre><code>Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
      if (desktop != null &amp;&amp; desktop.isSupported(Desktop.Action.BROWSE)) {
          try {
              URI uri = new URI("http://stackoverflow.com/");
              desktop.browse(uri);
  
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
      }
  </code></pre>