{"id":1418,"date":"2011-09-08T09:01:38","date_gmt":"2011-09-08T16:01:38","guid":{"rendered":"http:\/\/juixe.com\/techknow\/?p=1418"},"modified":"2011-09-08T21:37:34","modified_gmt":"2011-09-09T04:37:34","slug":"launch-default-web-browser-in-java","status":"publish","type":"post","link":"http:\/\/juixe.com\/techknow\/index.php\/2011\/09\/08\/launch-default-web-browser-in-java\/","title":{"rendered":"Launch Default Web Browser in Java"},"content":{"rendered":"<p>For the longest time I&#8217;ve used the <a href=\"http:\/\/browserlaunch2.sourceforge.net\/\">BrowserLauncher<\/a> library to open the default web browser to a specified web page from Java.  BrowserLauncher is simple to use, just import edu.stanford.ejalbert.BrowserLauncher and call openURL method with the desired website URL.<\/p>\n<p>Since Java 1.6, the JDK has introduced the java.awt.Desktop class to do the same so you don&#8217;t need an additional third party jar.  The Desktop class has the ability to launch the desktop&#8217;s default email client and default web browser given a URI.  Here is how you can launch the desktop&#8217;s default web browser in Java.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\/\/ Launch your default email client with ...\r\nURI email = new URI(&quot;mailto:myemail@mydomain.com&quot;);\r\nDesktop.getDesktop().mail(email);\r\n\r\n\/\/ Launch your default web browser with ...\r\nURI url = new URI(&quot;http:\/\/www.mydomain.com&quot;);\r\nDesktop.getDesktop().browse(url);\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>For the longest time I&#8217;ve used the BrowserLauncher library to open the default web browser to a specified web page from Java. BrowserLauncher is simple to use, just import edu.stanford.ejalbert.BrowserLauncher and call openURL method with the desired website URL. Since Java 1.6, the JDK has introduced the java.awt.Desktop class to do the same so you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[15,19],"tags":[541,540,543,542,802,544],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p902K-mS","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/1418"}],"collection":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/comments?post=1418"}],"version-history":[{"count":3,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/1418\/revisions"}],"predecessor-version":[{"id":1423,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/1418\/revisions\/1423"}],"wp:attachment":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/media?parent=1418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/categories?post=1418"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/tags?post=1418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}