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

0xCursor
  • 2,242
  • 4
  • 15
  • 33
Tony
  • 51
  • 1
  • 5
  • Can you boil down your attached source code to show what you do with your `JFrame`/`setDefaultCloseOpertaion` call? Reference: http://stackoverflow.com/questions/7799940/jframe-exit-on-close-java – Pedantic May 06 '14 at 18:53
  • I'm just using.... setDefaultCloseOperation(EXIT_ON_CLOSE); in the constructor that creates the frame. – Tony May 06 '14 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. – Tony May 06 '14 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. – Pedantic May 07 '14 at 03:45

1 Answers1

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.

Tony
  • 51
  • 1
  • 5