{"id":41132,"date":"2016-10-05T11:00:47","date_gmt":"2016-10-05T08:00:47","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=41132"},"modified":"2016-10-05T10:26:32","modified_gmt":"2016-10-05T07:26:32","slug":"close-application-properly","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/","title":{"rendered":"How to Close an Application Properly"},"content":{"rendered":"<p>In order to close Java program we need to consider which kind of Java application is it?, because termination of Java application varies between normal core java program to swing GUI application. In general all Java programs terminate automatically once all user threads created by program finishes its execution, including main thread.<\/p>\n<h2>1. Introduction<\/h2>\n<p>JVM doesn&#8217;t wait for daemon thread so as soon as last user thread finished, Java program will terminate. If you want to close or terminate your java application before this, your only option is to use <code>System.exit(int status)<\/code> or <code>Runtime.getRuntime().exit()<\/code>.<\/p>\n<p>This cause JVM to abandon all threads and exit immediately. Shutdown hooks are get called to allow some last minute clearing before JVM actually terminates. <code>System.exit()<\/code> also accept an int status parameter where a non zero value denote abnormal execute and the result returned by java command to caller. In this java tutorial we will see example of closing both Java program and Java Swing application.<br \/>\nSwing is a GUI widget toolkit for Java. It is part of Oracle\u2019s Java Foundation Classes (JFC) \u2013 an API for providing a graphical user interface (GUI) for Java programs. Swing was developed to provide a more sophisticated set of GUI components than the earlier <code>Abstract Window Toolkit (AWT)<\/code>. JAVA provides a rich set of libraries to create Graphical User Interface in platform independent way.<\/p>\n<h2>2. Java Swing<\/h2>\n<p>Unlike AWT, Java Swing provides platform-independent and lightweight components.\u00a0The javax.swing package provides classes for java swing API<\/p>\n<h3>2.1 MVC Architecture<\/h3>\n<p>Swing API architecture follows loosely based MVC architecture in the following manner.<\/p>\n<ul>\n<li>A Model represents component\u2019s data.<\/li>\n<li>View represents visual representation of the component\u2019s data.<\/li>\n<li>Controller takes the input from the user on the view and reflects the changes in Component\u2019s data.<\/li>\n<li>Swing component have Model as a seperate element and View and Controller part are clubbed in User Interface elements. Using this way, Swing has pluggable look-and-feel architecture.<\/li>\n<\/ul>\n<p>Every user interface considers the following three main aspects:<\/p>\n<ul>\n<li>UI elements : These are the core visual elements the user eventually sees and interacts with. GWT provides a huge list of widely used and common elements varying from basic to complex.<\/li>\n<li>Layouts: They define how UI elements should be organized on the screen and provide a final look and feel to the GUI (Graphical User Interface).<\/li>\n<li>Behavior: These are events which occur when the user interacts with UI elements.<\/li>\n<\/ul>\n<h3>2.2 Swing Features<\/h3>\n<p>Light Weight \u2013 Swing component are independent of native Operating System\u2019s API as Swing API controls are rendered mostly using pure JAVA code instead of underlying operating system calls.<\/p>\n<ul>\n<li>Rich controls \u2013 Swing provides a rich set of advanced controls like Tree, TabbedPane, slider, colorpicker, table controls.<\/li>\n<li>Highly Customizable \u2013 Swing controls can be customized in very easy way as visual apperance is independent of internal representation.<\/li>\n<li>Pluggable look-and-feel\u2013 SWING based GUI Application look and feel can be changed at run time based on available values.<\/li>\n<\/ul>\n<h3>2.3 Setup<\/h3>\n<p>Popular Java Editors:<br \/>\nTo write your java programs you will need a text editor. There are even more sophisticated IDE available in the market. But for now, you can consider one of the following:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<ul>\n<li>Notepad: On Windows machine you can use any simple text editor like Notepad TextPad.<\/li>\n<li>NetBeans: is a Java IDE that is open source and free which can be downloaded from <a href=\"http:\/\/www.netbeans.org\/index.html\">http:\/\/www.netbeans.org\/index.html<\/a>.<\/li>\n<li>Eclipse: is also a java IDE developed by the eclipse open source community and can be downloaded from <a href=\"http:\/\/www.eclipse.org\">http:\/\/www.eclipse.org<\/a><\/li>\n<\/ul>\n<p><b>Prerequisite<\/b><br \/>\nThis example is developed on Eclipse therefore a compatible Eclipse IDE is required to be installed on the system.<br \/>\nWe also need WindowBuilder tool to be installed on Eclipse IDE for the easiness of the work.<\/p>\n<h2>3. Example of Closing Java program using System.exit()<\/h2>\n<p>Here is a code example of closing Java program by calling System.exit() method. Remember non zero argument to exit() method like exit(1) denotes abnormal termination of Java application.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>ApplicationExit.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">import java.util.logging.Level;\r\nimport java.util.logging.Logger;\r\n\r\n\/**\r\n\u00a0*Java program which terminates itself by using System.exit() method , non zero call to exit() method denotes abnormal termination.\r\n\u00a0*\/\r\npublic class JavaCloseExample {\r\n\u00a0 \r\n\u00a0 \u00a0 public static void main(String args[]) throws InterruptedException {\r\n\u00a0 \u00a0 \r\n\u00a0 \u00a0 \u00a0 \u00a0Thread t = new Thread(){\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 @Override\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0public void run(){\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0while(true){\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0System.out.println(\"User thread is running\");\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 try {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Thread.sleep(100);\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 } catch (InterruptedException ex) {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Logger.getLogger(JavaCloseExample.class.getName()).log(Level.SEVERE, null, ex);\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0}\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0}\r\n\u00a0 \u00a0 \u00a0 \u00a0};\r\n\u00a0 \u00a0 \u00a0 \r\n\u00a0 \u00a0 \u00a0 \u00a0t.start();\r\n\u00a0 \u00a0 \u00a0 \u00a0Thread.sleep(200);\r\n\u00a0 \u00a0 \u00a0 \u00a0System.out.println(\"terminating or closing java program\");\r\n\u00a0 \u00a0 \u00a0 \u00a0System.exit(1); \/\/non zero value to exit says abnormal termination of JVM\r\n\u00a0 \u00a0 }\r\n}\r\n\r\nOutput:\r\nUser thread is running\r\nUser thread is running\r\nterminating or closing java program\r\nJava Result: 1 \u00a0\/\/1 is what we passed to exit() method\r\n\r\n<\/pre>\n<p>This Java program first creates a Thread\u00a0 in main method and start it, \u00a0which prints \u201cUser thread is running\u201d and then main thread sleeps for 200 Milli second. Till then, the other user thread is running and printing but once the main thread wakes up, it terminates the program by calling <code>exit()<\/code> method of <code>java.lang.System<\/code> class.<\/p>\n<h3>3.2 How to close Java swing application from program<\/h3>\n<p>Swing application mostly uses <code>JFrame<\/code> as top level container which provides two option to close swing GUI application from code. First option which is default is EXIT_ON_CLOSE which terminates Java swing GUI program when you click close button on <code>JFrame<\/code> window. Another option is <code>DISPOSE_ON_CLOSE<\/code> which terminates JVM if last displayable window is disposed off.<\/p>\n<p>Difference between <code>EXIT_ON_CLOSE<\/code> and <code>DISPOSE_ON_CLOSE<\/code> is that if you have a non daemon thread running it will not be closed in case of <code>DISPOSE_ON_CLOSE<\/code>, while <code>EXIT_ON_CLOSE<\/code> terminate JVM even if user thread is running. Run the below example by un comment <code>DISPOSE_ON_CLOSE<\/code> in your IDE and you can see user thread running even after clicking on close button. Here is a complete code example of closing Swing application in Java.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>ApplicationExit.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">import java.util.logging.Level;\r\nimport java.util.logging.Logger;\r\nimport javax.swing.JFrame;\r\n\r\n\/**\r\n\u00a0* Java swing program which terminates itself by calling \u00a0EXIT_ON_CLOSE and DISPOSE_ON_CLOSE\r\n\u00a0*\/\r\npublic class CloseSwingExample {\r\n\r\n\u00a0 \u00a0 public static void main(String args[]) throws InterruptedException {\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 JFrame frame = new JFrame(\"Sample\");\r\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); won't terminate JVM if user thread running\r\n\u00a0 \u00a0 \u00a0 \u00a0 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\r\n\u00a0 \u00a0 \u00a0 \u00a0 frame.setSize(200, 200);\r\n\u00a0 \u00a0 \u00a0 \u00a0 frame.setVisible(true);\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 Thread t = new Thread() {\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 @Override\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 public void run() {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 while (true) {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 System.out.println(\"User thread is running\");\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 try {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Thread.sleep(100);\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 } catch (InterruptedException ex) {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Logger.getLogger(CloseSwingExample.class.getName()).log(Level.SEVERE, null, ex);\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\r\n\u00a0 \u00a0 \u00a0 \u00a0 };\r\n\r\n\u00a0 \u00a0 \u00a0 \u00a0 t.start();\r\n\r\n\u00a0 \u00a0 }\r\n}\r\n\r\n<\/pre>\n<h3>3.3 Important Points for closing or terminating a Java application<\/h3>\n<ul>\n<li><code>System.exit()<\/code> actually calls <code>Runtime.getRuntime().exit()<\/code> method.<\/li>\n<li>Non zero argument to exit() denotes abnormal termination of Java program.<\/li>\n<li>Shutdown hooks are executed before Java program actually terminates.<\/li>\n<li>There are two options to close Java Swing application one is <code>EXIT_ON_CLOSE<\/code> and other is <code>DISPOSE_ON_CLOSE<\/code>.<\/li>\n<li><code>DISPOSE_ON_CLOSE<\/code> doesn&#8217;t terminate JVM if any user thread is running.<\/li>\n<li>You can also implement window listener to implement your closing mechanism by using <code>System.exit()<\/code> in Swing application.<\/li>\n<\/ul>\n<p>That&#8217;s all on how to close or terminate Java program. We have also seen example of closing Swing application in Java and difference between <code>EXIT_ON_CLOSE<\/code> and <code>DISPOSE_ON_CLOSE<\/code>.<\/p>\n<h2>4. Download The Source Code<\/h2>\n<p>This was an example of closing a Java application properly.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/10\/ApplicationExit.zip\"><strong>ApplicationExit<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In order to close Java program we need to consider which kind of Java application is it?, because termination of Java application varies between normal core java program to swing GUI application. In general all Java programs terminate automatically once all user threads created by program finishes its execution, including main thread. 1. Introduction JVM &hellip;<\/p>\n","protected":false},"author":98,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58],"tags":[],"class_list":["post-41132","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-swing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Close an Application Properly - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In order to close Java program we need to consider which kind of Java application is it?, because termination of Java application varies between normal\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Close an Application Properly - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In order to close Java program we need to consider which kind of Java application is it?, because termination of Java application varies between normal\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/jyoti.jha.9256\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-05T08:00:47+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jyoti Jha\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jyoti Jha\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/\"},\"author\":{\"name\":\"Jyoti Jha\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/7dcd033e37def0d21806e891845d89b7\"},\"headline\":\"How to Close an Application Properly\",\"datePublished\":\"2016-10-05T08:00:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/\"},\"wordCount\":958,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"articleSection\":[\"swing\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/\",\"name\":\"How to Close an Application Properly - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2016-10-05T08:00:47+00:00\",\"description\":\"In order to close Java program we need to consider which kind of Java application is it?, because termination of Java application varies between normal\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Desktop Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/desktop-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"swing\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/desktop-java\/swing\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"How to Close an Application Properly\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/7dcd033e37def0d21806e891845d89b7\",\"name\":\"Jyoti Jha\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Jyoti-Jha-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Jyoti-Jha-96x96.jpg\",\"caption\":\"Jyoti Jha\"},\"description\":\"Jyoti is a tech enthusiast and is an avid programmer. She holds a post graduation degree in (M.Tech) Computer Science Engineering from Thapar Univeristy, Patiala, India. Post her graduate studies, she has worked in Software companies such as SLK Software and Aricent, India as Software Engineer in various projects primarily in the field of Requirement analysis and design, implementing new algorithms in C++ and JAVA used in ISDN network and designing databases and. She is inquisitive about socio economic reforms as well as advancement in technical fronts and keep herself informed with TED talks and various blogs.\",\"sameAs\":[\"https:\/\/www.javacodegeeks.com\/\",\"https:\/\/www.facebook.com\/jyoti.jha.9256\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/jyoti-jha\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Close an Application Properly - Java Code Geeks","description":"In order to close Java program we need to consider which kind of Java application is it?, because termination of Java application varies between normal","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/","og_locale":"en_US","og_type":"article","og_title":"How to Close an Application Properly - Java Code Geeks","og_description":"In order to close Java program we need to consider which kind of Java application is it?, because termination of Java application varies between normal","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_author":"https:\/\/www.facebook.com\/jyoti.jha.9256","article_published_time":"2016-10-05T08:00:47+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Jyoti Jha","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Jyoti Jha","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/"},"author":{"name":"Jyoti Jha","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/7dcd033e37def0d21806e891845d89b7"},"headline":"How to Close an Application Properly","datePublished":"2016-10-05T08:00:47+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/"},"wordCount":958,"commentCount":1,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","articleSection":["swing"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/","name":"How to Close an Application Properly - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2016-10-05T08:00:47+00:00","description":"In order to close Java program we need to consider which kind of Java application is it?, because termination of Java application varies between normal","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/desktop-java\/swing\/close-application-properly\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Desktop Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/desktop-java\/"},{"@type":"ListItem","position":4,"name":"swing","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/desktop-java\/swing\/"},{"@type":"ListItem","position":5,"name":"How to Close an Application Properly"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/7dcd033e37def0d21806e891845d89b7","name":"Jyoti Jha","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Jyoti-Jha-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2016\/05\/Jyoti-Jha-96x96.jpg","caption":"Jyoti Jha"},"description":"Jyoti is a tech enthusiast and is an avid programmer. She holds a post graduation degree in (M.Tech) Computer Science Engineering from Thapar Univeristy, Patiala, India. Post her graduate studies, she has worked in Software companies such as SLK Software and Aricent, India as Software Engineer in various projects primarily in the field of Requirement analysis and design, implementing new algorithms in C++ and JAVA used in ISDN network and designing databases and. She is inquisitive about socio economic reforms as well as advancement in technical fronts and keep herself informed with TED talks and various blogs.","sameAs":["https:\/\/www.javacodegeeks.com\/","https:\/\/www.facebook.com\/jyoti.jha.9256"],"url":"https:\/\/examples.javacodegeeks.com\/author\/jyoti-jha\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/41132","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/98"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=41132"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/41132\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=41132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=41132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=41132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}