java.awt.Desktop vs Runtime.exec()
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.