1 package testapp; 2 3 import java.nio.file.Files; 4 import java.io.IOException; 5 import com.apple.eawt.Application; 6 import com.apple.eawt.AppEvent.OpenFilesEvent; 7 import com.apple.eawt.OpenFilesHandler; 8 import java.io.File; 9 import java.util.logging.Level; 10 import java.util.logging.Logger; 11 12 public class %APP_NAME% { 13 14 /** 15 * Mac OS requires specific treatment for handling file opening. 16 * We should provide a file handler which will do the job. 17 * Thus during the first launch the handler will be set. 18 */ 19 public static void main(String[] args) throws IOException { 20 System.out.println("Setting open files handler..."); 21 Application.getApplication().setOpenFileHandler(new OpenFilesHandler() { 22 23 @Override 24 public void openFiles(OpenFilesEvent ofe) { 25 for (File f : ofe.getFiles()) { 26 try { 27 Files.deleteIfExists(f.toPath()); 28 } catch (IOException ex) { 29 Logger.getLogger(%APP_NAME%.class.getName()).log(Level.SEVERE, null, ex); 30 } 31 } 32 } 33 }); 34 } 35 }