1

I've created a Java application and converted it to an .exe using Launch4j and it runs fine. But when it is closed, the "Java (TM) Platform SE Binary" task remains running in the Windows Task Manager. Each instance of the application I run creates a new task for this and they need to be manually end-tasked.

Any ideas why this would happen? I've only been coding in Java for about 3 weeks and this is my first application.

Hope it's ok to add links to the application + zipped source code. I can't add the source code directly as it is too long. Thanks for any advice or suggested solutions.

Application: http://www.filedropper.com/folderencryptor

Source Code: http://www.filedropper.com/folderencryptor_1

4
  • Can you boil down your attached source code to show what you do with your JFrame/setDefaultCloseOpertaion call? Reference: stackoverflow.com/questions/7799940/jframe-exit-on-close-java Commented May 6, 2014 at 18:53
  • I'm just using.... setDefaultCloseOperation(EXIT_ON_CLOSE); in the constructor that creates the frame. Commented May 6, 2014 at 19:34
  • DOH!!! I forgot to add optFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); to the Option window frame. So it just got hidden when the close button was pressed. Thanks for your link Pedantic...that helped me realise my mistake. I appreciate the time you took to respond to this newbies question. Commented May 6, 2014 at 19:47
  • 1
    No problem. If you can explain here in an answer, and accept it for yourself you'll get some reputation and help others who search for this problem in the future. Commented May 7, 2014 at 3:45

1 Answer 1

1

I forgot that my application opened another JFrame to display some options and I had not set any action to occur when the close button in the frame was pressed. By default, Java sets it to 'hide the frame' when closed(not helpful Java!!). So Java was still using the frame, and hence the Windows task was still running.

So all I had to do was add...

optFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)

...inside the initialization code for the options JFrame. In short, don't forget to dispose of JFrames when you're done with them.

Sign up to request clarification or add additional context in comments.

1 Comment

Accept this as an answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.