I need to execute a method, (a method which creates a file), when I exit my program, how would I do this?
addWindowListener is better solution:
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
// run methods before closing
try {
Runtime.getRuntime().exec("taskkill /f /im java.exe");
} catch (IOException e4) {
// TODO Auto-generated catch block
e4.printStackTrace();
}
}
});