JDesktop Integration Components, JDIC, is a Java desktop project at
www.java.net that focuses on using native and platform-specific applications
and facilities. According to the site -the JDesktop Integration Components
(JDIC) project aims to make Java technology-based applications ('Java
applications') first-class citizens of current desktop platforms without
sacrificing platform independence. JDIC provides Java applications with access
to facilities provided by the native desktop such as the mailer, the browser,
and registered document viewing applications. Additionally it provides the
mechanisms by which Java applications can integrate into the native desktop such
as registering Java applications as document viewers on the desktop and creating
installer packages.Â
|
In the past issues of PCQuest we have carried articles on embedding a Web
browser (Internet Explorer) in a Java application and installing the Java
application on the Windows system tray, using JDIC. In this article, we look at
yet another feature of JDIC, which allows launching the native applications
through Java. To understand how this is useful, consider the following example.
Suppose you are writing a network browser application in Java and you browse
through several files, and then you double click on a .doc file. Ideally, the
Java network browser should launch MS Word and show the clicked .doc file. With
JDIC, you can achieve this very easily. It also allows a Java application to
edit and print a file, which will again launch the associated native
applications.
But it does not stop here. You can launch the default e-mail client (say
Outlook on a Windows desktop). What's more, you can pre-fill the To:, CC:, BCC:,
Subject: and the body of the e-mail. And you can also add attachments.Â
We go through short code snippets to understand how to code the
above-mentioned things with JDIC. To compile and run the code below, you must
install J2SDK version 1.4.2 or above which can be downloaded from java.sun.com.
Also download the latest version of JDIC for Windows from
https://jdic.dev.java.net. For this article we downloaded and used version 0.9.1
(filename: jdic-0.9.1-bin-windows.zip), which was the latest version as of this
writing. We used J2SDK 1.5.0_01 (JDK 5 update 1) to compile and run the code.
For convenience, put the bin directory of J2SDK installation in the PATH, so
that 'javac ' and 'java' can be from anywhere.Â
Create a directory named pcq and copy the files named jdic.jar and
jdic.dll-which you will find in the zip archive-to this directory.Â
Read the complete tutorial at PCQuest