package sample; import java.awt.Desktop; import java.awt.GraphicsEnvironment; public class DesktopTest { // static { // System.setProperty("java.awt.headless" , "true"); // } /** * Check availability of the Dektop API and its features * * @param args no arguments needed */ public static void main(String[] args) { if (GraphicsEnvironment.isHeadless()) { System.err.println("Application runs in headless mode"); System.exit(1); return; } if (!Desktop.isDesktopSupported()) { System.err.println("Desktop API not available"); System.exit(1); return; } Desktop desktop = Desktop.getDesktop(); // URI sample: new URI("http://java.sun.com/"); System.out.println("desktop.browse(URI) : " + desktop.isSupported(Desktop.Action.BROWSE)); // URI sample: // new URI("mailto", // "duke@sun.com?SUBJECT=Happy New Year!&BODY=Happy New Year, Duke!", // null); System.out.println("desktop.mail(URI) : " + desktop.isSupported(Desktop.Action.MAIL)); // File sample: new File("Test.txt"); System.out.println("desktop.open(File) : " + desktop.isSupported(Desktop.Action.OPEN)); System.out.println("desktop.edit(File) : " + desktop.isSupported(Desktop.Action.EDIT)); System.out.println("desktop.print(File) : " + desktop.isSupported(Desktop.Action.PRINT)); } }