title: Open a browser with java
body: <p>I hava a java program with two buttons, one for chrome and one for firefox. I press  one of them, and the browser starts at  some particualar location on the screen and with smalles size.</p>
  
  <p>i have try running terminal commands, something like this</p>
  
  <pre><code>"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"  --profile-directory="Default" --app="data:text/html,&lt;html&gt;&lt;body&gt;&lt;script&gt;window.moveTo(198,60);window.resizeTo(1167,708);window.location='https://stackoverflow.com';&lt;/script&gt;&lt;/body&gt;&lt;/html&gt;"
  </code></pre>
  
  <p>And it works, but only for chrome. I want at least chrome and firefox on both windows and linux.</p>
  
  <p>Searching a little I have come across other solution. Running javascript on java, somethig like:</p>
  
  <pre><code>    ScriptEngineManager factory = new ScriptEngineManager();
      ScriptEngine engine = factory.getEngineByName("JavaScript");             
      engine.eval("window.open('https://stackoverflow.com')");
      engine.eval("window.resizeTo(800,600)");
  </code></pre>
  
  <p>But Im getting compilation errors:</p>
  
  <pre><code>ReferenceError: "window" is not defined in &lt;eval&gt; at line number 1
  </code></pre>
  
  <p>And I don´t know whats going. Ideas?</p>