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 13:52:01 +0100 Lines: 64 Message-ID: References: <10fc56da-c03f-41a7-93b8-c7eeb6d24279@googlegroups.com> <7b27f662-d2e0-4649-8e4d-5e14e790bd14@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net Nh4NpTa4VxK3cfqqj+AHZQLGGPI7zD+9J0nGsZSmNctxGAjyXt Cancel-Lock: sha1:mdub5q9t1GodBvnTKKzFgmnAvVc= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 In-Reply-To: <7b27f662-d2e0-4649-8e4d-5e14e790bd14@googlegroups.com> Xref: csiph.com comp.lang.java.programmer:35452 On 25/08/16 13:24, Eric Douglas wrote: > On Wednesday, August 24, 2016 at 5:40:23 PM UTC-4, Eric Sosman wrote: >>> Appears to be a bug in the JRE? I tried the simplest program, [...] >> >> Code? > > I mean as simple as simple can be. There's a JNLP pointing to a test server set up on IIS. 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). > > > > > > > > > > > > > > > and that jar packaged in that one class. > package com.javatest; > > import java.awt.EventQueue; > > import javax.swing.JDialog; > > public class SimpleTest { > public SimpleTest() { > EventQueue.invokeLater(new Runnable() { > > @Override > public void run() { > showGui(); > } > }); > } > > public static void main(String[] args) { > new SimpleTest(); > } > > private void showGui() { > final JDialog frame = new JDialog(); > frame.setTitle("Testing"); > frame.setVisible(true); > } > > } > > The JVM does terminate itself if I set Java in the Control Panel to hide the console, but if that console is visible it stays open deadlocked until I hit the Close button. In our regular application I can run with the console window visible and it disappears when the program ends, but we're starting from a third party jar so I can only guess they're calling System.exit(). I assume this is why no one cares that the JVM doesn't terminate, because end users normally hide the console window. I'm used to that window disappearing on it's own so when I wrote a standalone program and it didn't disappear I assume I missed something or it's a bug. >