O'Reilly logo

Java™ How to Program, Seventh Edition by P. J. Deitel - Deitel & Associates, Inc., H. M. Deitel - Deitel & Associates, Inc.

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

G.3. Desktop Class

Java SE 6’s new Desktop class enables you to specify a file or URI that you’d like to open using the underlying platform’s appropriate application. For example, if Firefox is your computer’s default browser, you can use the Desktop class’s browse method to open a web site in Firefox. In addition, you can open an email composition window in your system’s default email client, open a file in its associated application and print a file using the associated application’s print command. Figure G.2 demonstrates the first three of these capabilities.

Figure G.2. Use Desktop to launch the default browser, open a file in its associated application and compose an email in the default email client.
 1 // Fig. G.2: DesktopDemo.java
 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required