main() returns, but app does not exit

D

David Thielen

Hi;

Any ideas why my app runs fine, returns on the final line of main -
but doesn't exit because it's stuck in the jvm somewhere and won't
exit that?

It seems to be spinning in Wtoolkit. There is nothing in my code that
does a wait. I do a bunch of file I/O but I close all the streams
before I exit.

Any ideas on how to go about finding this?

thanks - dave

david@[email protected]
Windward Reports -- http://www.WindwardReports.com
DefendTek -- http://www.DefendTek.com
Page 2 Stage -- http://www.Page2Stage.com
Enemy Nations -- http://www.EnemyNations.com
me -- http://dave.thielen.com
Barbie Science Fair -- http://www.BarbieScienceFair.info
Hillary Clinton -- http://www.HillaryIn2004.org
(yes I have lots of links)
 
B

Brad BARCLAY

David said:
Any ideas why my app runs fine, returns on the final line of main -
but doesn't exit because it's stuck in the jvm somewhere and won't
exit that?

Do you have any non-daemon threads left running?

You really should be calling System.exit(0) (or whatever return code
you want to provide) at the end of your main method to tell the JVM to
cleanup and exit properly.

Brad BARCLAY
 
A

Andrew Thompson

....
Any ideas why my app runs fine, returns on the final line of main -
but doesn't exit because it's stuck in the jvm somewhere and won't
exit that?

...it probably has something to do with MS.
It seems to be spinning in Wtoolkit.

That seems to be part of Visual J++, which
suggests several possible answers.

a) upgrade from this obsolete IDE.

[ Under no circumstances would I
recommend upgrading to MS's 'J++',
which seems like yet another garden path
up which MS wishes to lead developers
(they must be having fun..) ]

c) use Java resources made by the creator
of Java - Sun, or write in C# for .NET

HTH
 
D

David Thielen

C:\src\xmlreport>java -version
java version "1.3.1_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_08-b03)
Java HotSpot(TM) Client VM (build 1.3.1_08-b03, mixed mode)

C:\src\xmlreport>

I don't think that's MS.

- dave


...
Any ideas why my app runs fine, returns on the final line of main -
but doesn't exit because it's stuck in the jvm somewhere and won't
exit that?

..it probably has something to do with MS.
It seems to be spinning in Wtoolkit.

That seems to be part of Visual J++, which
suggests several possible answers.

a) upgrade from this obsolete IDE.

[ Under no circumstances would I
recommend upgrading to MS's 'J++',
which seems like yet another garden path
up which MS wishes to lead developers
(they must be having fun..) ]

c) use Java resources made by the creator
of Java - Sun, or write in C# for .NET

HTH


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
DefendTek -- http://www.DefendTek.com
Page 2 Stage -- http://www.Page2Stage.com
Enemy Nations -- http://www.EnemyNations.com
me -- http://dave.thielen.com
Barbie Science Fair -- http://www.BarbieScienceFair.info
Hillary Clinton -- http://www.HillaryIn2004.org
(yes I have lots of links)
 
D

David Thielen

Found it - it's the call:
ImageIcon ii = new ImageIcon(buf);

Why is another story. There is no close for this call so it shouldn't
do this!!!

- dave



...
Any ideas why my app runs fine, returns on the final line of main -
but doesn't exit because it's stuck in the jvm somewhere and won't
exit that?

..it probably has something to do with MS.
It seems to be spinning in Wtoolkit.

That seems to be part of Visual J++, which
suggests several possible answers.

a) upgrade from this obsolete IDE.

[ Under no circumstances would I
recommend upgrading to MS's 'J++',
which seems like yet another garden path
up which MS wishes to lead developers
(they must be having fun..) ]

c) use Java resources made by the creator
of Java - Sun, or write in C# for .NET

HTH


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
DefendTek -- http://www.DefendTek.com
Page 2 Stage -- http://www.Page2Stage.com
Enemy Nations -- http://www.EnemyNations.com
me -- http://dave.thielen.com
Barbie Science Fair -- http://www.BarbieScienceFair.info
Hillary Clinton -- http://www.HillaryIn2004.org
(yes I have lots of links)
 
A

Andrew Thompson

.....
(top-posting corrected)
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_08-b03)
Java HotSpot(TM) Client VM (build 1.3.1_08-b03, mixed mode)

Good for you Dave. But Sun did not write
'Wtoolkit', which is where _you_ stated
you felt the problem was.

I can only go on the information provided.
 
M

Michael Borgwardt

David said:
Found it - it's the call:
ImageIcon ii = new ImageIcon(buf);

Why is another story. There is no close for this call so it shouldn't
do this!!!

Um, that's a Swing component. If you have a Swing or AWT GUI then OF COURSE
the app will keep running after the main method ends because there could be
user input from the GUI.
 
D

David Thielen

It turns out using ImageIcon() causes this problem. No idea why but
that was the cause.

- dave


Hi;

Any ideas why my app runs fine, returns on the final line of main -
but doesn't exit because it's stuck in the jvm somewhere and won't
exit that?

It seems to be spinning in Wtoolkit. There is nothing in my code that
does a wait. I do a bunch of file I/O but I close all the streams
before I exit.

Any ideas on how to go about finding this?

thanks - dave

david@[email protected]
Windward Reports -- http://www.WindwardReports.com
DefendTek -- http://www.DefendTek.com
Page 2 Stage -- http://www.Page2Stage.com
Enemy Nations -- http://www.EnemyNations.com
me -- http://dave.thielen.com
Barbie Science Fair -- http://www.BarbieScienceFair.info
Hillary Clinton -- http://www.HillaryIn2004.org
(yes I have lots of links)


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
DefendTek -- http://www.DefendTek.com
Page 2 Stage -- http://www.Page2Stage.com
Enemy Nations -- http://www.EnemyNations.com
me -- http://dave.thielen.com
Barbie Science Fair -- http://www.BarbieScienceFair.info
Hillary Clinton -- http://www.HillaryIn2004.org
(yes I have lots of links)
 
C

Chris Gokey

Probably threads that are running behind the scene when you instantiate
these swing/awt classes. If you want to ensure an exit, add:
System.exit(0);

To the last line of your main.

Chris

David said:
It turns out using ImageIcon() causes this problem. No idea why but
that was the cause.

- dave





david@[email protected]
Windward Reports -- http://www.WindwardReports.com
DefendTek -- http://www.DefendTek.com
Page 2 Stage -- http://www.Page2Stage.com
Enemy Nations -- http://www.EnemyNations.com
me -- http://dave.thielen.com
Barbie Science Fair -- http://www.BarbieScienceFair.info
Hillary Clinton -- http://www.HillaryIn2004.org
(yes I have lots of links)


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet
News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World!
Privacy via Encryption =---

--
 
D

David Thielen

This shouldn't be happening in my case - I never create any windows or
other threads. I just used ImageIcon to the the width & height of the
image.

I'm sure it is due to awt starting some thread - but it shouldn't.

- dave



Probably threads that are running behind the scene when you instantiate
these swing/awt classes. If you want to ensure an exit, add:
System.exit(0);

To the last line of your main.

Chris


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
DefendTek -- http://www.DefendTek.com
Page 2 Stage -- http://www.Page2Stage.com
Enemy Nations -- http://www.EnemyNations.com
me -- http://dave.thielen.com
Barbie Science Fair -- http://www.BarbieScienceFair.info
Hillary Clinton -- http://www.HillaryIn2004.org
(yes I have lots of links)
 
T

Tony Morris

It is likely that you have a non-daemon thread running.
The JVM will exit only when there are no non-daemon threads running or a
forced shut down with System.exit(int) [not recommended].

The likely candidate thread that is causing this problem is the AWT Event
Dispatch thread that is still running. I could go into more detail but
would only be repeating what the Sun tutorial says.

Good luck.

--
Tony Morris
(BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
Software Engineer
IBM Australia - Tivoli Security Software

David Thielen said:
It turns out using ImageIcon() causes this problem. No idea why but
that was the cause.

- dave


Encryption =---


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
DefendTek -- http://www.DefendTek.com
Page 2 Stage -- http://www.Page2Stage.com
Enemy Nations -- http://www.EnemyNations.com
me -- http://dave.thielen.com
Barbie Science Fair -- http://www.BarbieScienceFair.info
Hillary Clinton -- http://www.HillaryIn2004.org
(yes I have lots of links)


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
J

John

It is not clear from your post, but this may be of use :
http://www.javapractices.com/Topic50.cjp

For Swing applications, the termination of the initial main method does
not mean that the program terminates. This is because GUI apps launch
another thread called the Event Dispatch Thread, which keeps the program
alive, even after the initial main returns.

Note that the launch thread of any GUI application is in effect an
initial worker thread - it is not the event dispatch thread, where the
bulk of processing takes place.

Might also be of interest :
http://www.javapractices.com/Topic149.cjp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top