File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Program wont terminate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Program wont terminate" Watch "Program wont terminate" New topic

Program wont terminate

Jonathan Steel

Joined: Jan 26, 2005
Posts: 13
When I run the code below everything works as it should when a parameter is passed. But if no parameter is passed then the message box is displayed, I press ok, and then nothing happens. The program continues to run.

public static void main(String[] args) {
if (args.length == 1) {
CImageViewerDispatch ivd = new CImageViewerDispatch(args[0]);
else {
JOptionPane.showMessageDialog(null, "Wrong number of arguments in program parameter list");


Do i need to release the message box from memory or something?
Tad Dicks
Ranch Hand

Joined: Nov 16, 2004
Posts: 264
you need a system exit call.


call this on close of the window. Or on return from the Dialog message.

xxx yyyy

Joined: Feb 20, 2005
Posts: 2
When you call JOptionPane.showMessageDialog(...) a Message Dialog (a Swing Component) is "realized". After this swing starts its event-dispatching thread.

Now you close the message dialog and the main-thread terminates, but
the swing event-dispatching thread is still running (the event-dispatching thread is not a "demeon" thread).
This is the reaseon why the VM does not exit.

Joern Kottmann
I agree. Here's the link:
subject: Program wont terminate
It's not a secret anymore!