I’m using the following method to display a frame:
public static void createImage(final String url, final String file, final String filetype) {
UIUtils.setPreferredLookAndFeel();
NativeInterface.open();
SwingUtilities.invokeLater(new Runnable() {
@SuppressWarnings("deprecation")
@Override
public void run() {
frame = new JFrame();
WebsiteThumbnailCreator ex = new WebsiteThumbnailCreator(url, file, filetype);
frame.getContentPane().add(ex, BorderLayout.CENTER);
frame.setSize(FRAMESIZE);
frame.setLocationByPlatform(true);
frame.setVisible(true);
frame.hide();
}
});
NativeInterface.runEventPump();
}
Then i do some calculation and after that, I want to dispose the frame again:
try {
ImageIO.write(rendered, filetype, new File(file + "." + filetype));
frame.dispose();
logger.trace("Tried to dispose the frame");
} catch (IOException e) {
logger.fatal(e.getMessage());
} finally {
logger.debug("Try to dispose the frame");
frame.dispose();
}
I can see the log messages but however, the VM is still running. I want to also terminate it. What am I doing wrong?
There seems to still be running one non deamon thread, but I can’t see why:

You’re not setting the JFrame’s default close operation and it’s defaulting to
JFrame.HIDE_ON_CLOSE.Add to your JFrame set up code:
If your JFrame is your application and you want to exit everything when the JFrame closes, or
if your JFrame is not the whole application and you want to stop the Swing thread but continue processing.
For more on this, please check out the JFrame API
Edit:
Regarding your comment,
Which I translate to:
This only exits if there are no more non-daemon threads left. If you give it a non-daemon thread, this will keep running. For e.g.,
Your code will keep running in this example.