Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Nigel Wade Newsgroups: comp.lang.java.programmer Subject: Re: How do I terminate a JVM properly? Date: Thu, 25 Aug 2016 15:04:28 +0100 Lines: 28 Message-ID: References: <10fc56da-c03f-41a7-93b8-c7eeb6d24279@googlegroups.com> <7b27f662-d2e0-4649-8e4d-5e14e790bd14@googlegroups.com> <4fe5062e-9db3-4e91-9cfb-deeb8d51461a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 91glqvGWyWNRwvJPdIHidgerqjlzxgP7rzJGhX2z0Y20nhemvl Cancel-Lock: sha1:bicuT/qOLx1hNrXvUnuLUSqJ1GM= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 In-Reply-To: <4fe5062e-9db3-4e91-9cfb-deeb8d51461a@googlegroups.com> Xref: csiph.com comp.lang.java.programmer:35455 On 25/08/16 14:05, Eric Douglas wrote: > On Thursday, August 25, 2016 at 8:52:12 AM UTC-4, Nigel Wade wrote: >> In your original post you stated that: >> "After I dispose the last GUI object the JVM should terminate itself." >> >> Indeed it should. But where exactly, in the code below, do you dispose of the GUI objects you've created? >> (FYI, close != dispose). >> >> The EDT will not exit as long as there are displayable components left which the JVM is managing. >> (displayable != visible). >> > > It appears to destroy the window when you click the X. It closes the window. Nothing else. > DISPOSE_ON_CLOSE is not the default? Let's try adding that. No, it's not the default. > I normally set windows to DO_NOTHING_ON_CLOSE with a WindowListener looking for the close event to do some cleanup before calling dispose(). I left that out of the simple test thinking it shouldn't be necessary. > I do remember testing yesterday that the window was showing isDisplayable() = true before calling dispose(). > > So, if console is visible (as a developer mine normally is, I put debug messages in there), the JVM stays active apparently on a deadlock until you manually close the console with it's Close button. With an explicit call to dispose the JVM does terminate if console is not visible. (our normal application API does automatically close that console window, must be calling System.exit) Is the JVM still running, or just the console? I don't use Windows much, so wouldn't know what the Windows Java console window does. If you want to know if your application is exiting cleanly run it from the command line and see if it exits.