how to close the applet in java code?

How to close java Applet through code

  • I am developing a java applet. I want it to be closed by the code. I have used System.Exit(0) but it is not working. Is there any other method to achieve this? Thanks

  • Answer:

    An applet cannot call System.exit(int);. Security permissions don't let an applet do this. And if you are trying to close the browser window, even if you signed the code and the browser/user trusted you, the browser wouldn't let you shutdown/close the browser window. If all you want to do is close a Window/Frame created from the applet, this is no different than closing a window outside of an applet.

Rashmi at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

applet.getAppletContext().showDocument("ThanksForUsingOurApplet.html"); As to the comment that a signed applet can call System.exit(n). It can in some browser/JRE combos., it can't in others. In the ones that it can, it shouldn't since an applet may share a VM with other applets (less common these days), and even if not, it is the user's responsibility to close an applet by closing the page. An applet is a guest in a web page. Calling System.exit(n) is like burning down the guest house.

Andrew Thompson

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.