View Full Version : Java terminal/command line
I have a Java program that runs on the terminal. Is there any way of calling code when the user closes the window just before the terminal closes?
iGoD ReLeNtLeS
23-03-11, 19:04
i believe you can use the addShutdownHook, i think thats what you on about. To execute some code when the terminal window is closed or its stopped using Ctrl + C
http://download.oracle.com/javase/6/docs/api/java/lang/Runtime.html#addShutdownHook%28java.lang.Thread%29
Try that ;)
Don't think you'll be able to as you could add code to make unclosable windows by making a new one when the old one is closed?
i believe you can use the addShutdownHook, i think thats what you on about. To execute some code when the terminal window is closed or its stopped using Ctrl + C
http://download.oracle.com/javase/6/docs/api/java/lang/Runtime.html#addShutdownHook%28java.lang.Thread%29
Try that ;)
Cheers, that worked.
Powered by vBulletin® Version 4.1.12 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.