Browse DevX
Sign up for e-mail newsletters from DevX


Take Charge of Desktop Integration with Java SE 6 : Page 2

With the release of the Java Standard Edition 6.0 Beta, Java developers no longer need to contend with clamp-on solutions or Java Native Interface (JNI) to make their applications interact with desktop products and features. These desktop-integration features now are part of the core.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Ant Before the Horse

You will use Apache Ant to build the application. So if you don't have it already, download Apache Ant from the Apache Web site and install it on your computer.

A check of the Ant Java version using the following Ant property reveals an incorrect Java version:


This is because Ant's built-in ant.java.version system property is designed to hold only 1.1, 1.2, 1.3, 1.4, and 1.5 values. The Ant development team will likely update this property soon to include 1.6, but you are playing with bleeding edge technology in this case.

For the persnickety, running Ant with –debug will show the following, which means Ant in fact is using a 1.6 JRE:

>> Detected Java version: 1.5 in: C:\Program Files\Java\jdk1.6.0\jre <<

Trot Before You Gallop

Next, set up your development environment. The simplest way to do that is to download the accompanying code for this article and extract its contents. If you extract the ZIP file on your C:\ drive, you should see the following file and directories:

c:\mustang\ |_build.xml +_src

You will use build.xml, the Ant build file, to copy, compile, build, package, and run the GoMustang application. It contains the following key Ant targets:

[init] [clean] [compile] [dist] [run]

The [init] target sets up the folder structure and copies files to the build folder; [compile] does the compilation, while [dist] creates a jar with a Manifest file (more on this later). The [run] target comes in handy for launching your application, while [clean] is useful if you want to start with a clean slate and delete all the files and directories created by any of the Ant tasks.

The src directory contains three files: GoMustang.java (the source code file) and two GIF files (gomustang-splash.gif is used as a splash screen, and gomustang.gif is used as an icon in the system tray).

Now that you understand the basics, you can jump right into creating a splash screen for your application.

The Splash Screen

Splash screens for desktop-based applications have always played a vital role in the applications' perceived start-up response times. A sharp splash screen can keep the user engaged at the start of the application by displaying marketing blurbs, legal and statutory fine print, professional images, etc. Meanwhile, it provides the application cycles to load the required libraries.

Splash screens for Java-based applications have always been a challenge because Java applications do not get control until the JVM has started and all the required JRE and application libraries have been loaded. By the time a Java application gets control of the thread, it's too late to show a splash screen.

Java SE 6 allows an application to show a splash screen even before the JVM starts. This functionality is built into the Java application launcher, which can display an image in an undecorated window. It allows GIF, PNG, or JPEG images, with transparency, translucency, and animation. Furthermore, it comes bundled with the SplashScreen class, which allows manipulation of the splash screen once an application gains control of the thread.

You can launch a splash screen in the following two ways:

  1. Specify a special SplashScreen-Image attribute in a JAR's Manifest file
  2. Use a command line -splash parameter

Thanks for your registration, follow us on our social networks to keep up-to-date