408
Chapter 11
C H A P T E R E L E V E N
Native Integration
and Packaging
Hacks 79–87
You can try really hard to develop a desktop application that looks good,
feels right, and meets the user’s needs, but if a Windows or Mac user has to
drop down to a command line and type
java -jar MyCoolApp.jar to run it,
it’s not going to win you any points in the user experience department.
There are points of integration with the native platform that you’ll often
want and need to access from a Swing application, or specific functionality
you’ll want to provide on a platform-by-platform basis, and that’s what this
chapter is about.
Actually, this chapter was almost rendered irrelevant by the
JDesktop Integration Components (JDIC) project on Java.net
(https://jdic.dev.java.net/), which is addressing the most seri-
ous needs for desktop Java applications: creating platform-
appropriate double-clickables, providing access to the native
web browser component, associating Java applications with
certain kinds of documents, etc. JDIC may solve some of the
biggest issues facing Java on the desktop…which leaves us all
the more room for creative hackery.
H A C K
#79
Launch External Programs on Windows Hack #79
With one simple command you can tell Windows to open files, directories,
and URLs on your behalf.
Swing programmers have always had difficulty dealing with native operat-
ing systems because of Java’s cross-platform nature. Even simple things like
opening a web browser require building native hooks with JNI or building
on top of custom libraries. This hack will show you how to open files,
URLs, and start an email app without using any native libraries or custom C
coding.

Get Swing Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.