// nur eine Instanz erlauben
File lockFile = new File("Lock");
try {
if (lockFile.createNewFile()) {
lockFile.deleteOnExit();
System.out.println("create Lock-File");
}
else {
// Meldung ausgeben
JOptionPane msg = new JOptionPane();
msg.showMessageDialog( null, "Programm is still running");
// Programm beenden
System.exit(0);
}
}
catch(IOException ioe){ System.out.println("could not create Lock-File");}