Urgaan Urgaan - 3 months ago 24
Java Question

Program stays in memory after close

I'm making an interface for something and it is in fullscreen, so I can't click the X button to close it. In order to get around this I wanted to use esc as a close feature, this is my code for it

if(key == KeyEvent.VK_ESCAPE){
frame.setVisible(false);
stop();
frame.dispose();
}


When I press esc it closes, I can't see it active in my task screen, but when I go to task manager and then processes, it shows javaw.exe still being there and using memory. Is there anything I can do to fix this?

Edit: No this was not on how to exit a java program from within the code, it was about it staying loaded it the memory.

Answer

If you want to shut down the JVM, you can use System.exit(0);. Your code only disposes the interface, it doesn't stop the program.