How to close application when System.exit(0) does not works?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-07 02:17:22

问题


I have a application. On Close button click I am calling System.exit(0). But on a machine it is not getting close that application. It is happening on few systems not all.

I read some docs and forums and found that the exit() with 0 (zero) int value is used for normal exit. and normally this method never returns normally (means close the application). BUT if a security manager exists and its checkExit method doesn't allow exit with the specified status.

My application is not creating any Security Manager and I know also that By default an application does not have a security manager. That is, the Java runtime system does not automatically create a security manager for every Java application. So by default an application allows all operations that are subject to security restrictions.

I am also not sure that it is happening due to security manager.

Now I want to know two things.

  1. Can I close the application successfully with the existence of system manager, How ?

  2. Does System.setSecurityManager(null); is the right way to do this ?

I have to close my application by any way. Any suggesstion ?

Thanks

Tej Kiran

来源:https://stackoverflow.com/questions/10380257/how-to-close-application-when-system-exit0-does-not-works

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!