Posted by ixmal
on May 10, 2006 at 4:19 PM PDT
There is a new class introduced in Mustang,
java.awt.Desktop, which helps developers to better integrate their applications into native desktop. This blog briefly shows what new abilities are provided by this class.
Desktop API vs Runtime.exec()
I'm often asked why is that new class,
java.awt.Desktop, is introduced. They state all the required actions can be performed with the call to one of
is close to
Runtime.getRuntime().exec("start " + filename);
So I decided to write a couple of words about this issue to answer the most of such questions at once:)
The difference is...
The problem with the "start" invocation is that it only works on the Windows platform. It will fail on the Mac, Linux, and Solaris platforms. With the Desktop API, you can be guaranteed that it will start an application on all platforms.
There are also lots of other handy features in the new API, such as open, edit, print, and two special actions - browse and mail - that launch separate processes.
java.awt.Desktop JavaDoc for details.