Note that there are some explanatory texts on larger screens.

plurals
  1. POlaunching and closing a native browser that points to web app
    text
    copied!<p>Hello good Stack Overflow people, I do have a business problem and would like to get some answers/pointers/ideas on how to go about solving it. perhaps this has been mentioned in some other topic but so far I searched the internet but not able to find a straight answer..</p> <p><em>Business Problem: One of our clients would like to have a Java web based application but launched as a desktop application. i.e. the client would like to double click on an icon some where on their desktop and get a browser window launched pointing to the URL/context of the web application which will be running <strong>locally</strong> on a Jetty server that will get started up when the user clicks on the icon.</em></p> <p>So far I have figured out how to package my application and create an exe launcher (using install4j) (basically i created an executable jar file with jetty server and my web app packaged together with a startup class that will start Jetty server and point it to the context of the web application).</p> <p>My problem is I have no idea how to start up a (native) web browser and point it to the URL/context of the web app.</p> <p>I have found this code that launch the user's default browser:</p> <pre><code>String url = "http://www.google.com"; java.awt.Desktop.getDesktop().browse(java.net.URI.create(url)); </code></pre> <p>which is good but not good enough. and the reason its not good enough is that when the user close the browser the Jetty server would still be running in the back ground. What I want is when the user closes the browser I also want to detect this event and close down the Jetty server (without using any active X or JavaScript please)</p> <p>Some one have mentioned creating a JPanel and include a native browser inside it using some DJ native swing API but I have no clue as how to do this.</p> <p>Any ideas?</p> <p>Many thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload