简体   繁体   中英

How to execute a set of commands when exiting a java program?

i want to execute a particular set of commands when the program exits by pressing the cross on the right hand top corner

Depending of what you really want to do, there are few ways to do it:
1) If you want to do it on UI level use WindowListener [link]
2) If you want to do it on JVM level, use ShutdownHooks [link]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM