Java Advanced Imaging

From I Do Imaging
Jump to: navigation, search


Java Advanced Imaging (JAI) is a set of tools available from Oracle that can be added to a Java installation. Its relevance to imaging software is that it can perform image compression, used in many medical image file formats.

JAI has a Java component and a native (machine-dependent) component, so is not available on all platforms. Currently there is no free JAI and JAI-IO for the Macintosh platform, or for 64-bit Java on the Windows platform (which is the most common).



JAI is now a community-supported project independent of Oracle, and can be tricky to find. Currently the software is hosted at Be sure to download the correct versions, first of the JAI latest version and then the JAI I/O Tools . The download files are named by OS (linux, windows), platform (you'll want amd64 for all 64-bit processors, Intel as well as AMD, or i586 in the unlikely case you're running 32 bit Java), Java version (jdk or jre, as above), and file format (we used bin). Carefully select and download the JAI and JAI-IO files.

Preparing the downloaded files

You'll need to make both files executable, and the JAI-IO file needs a slight modification to overcome an error in the 'tail' command (thank you JGrass Tech Tips).

$ ls -l jai*
-rwxr-xr-x 1 ahc users 3580002 Sep 18  2006 jai-1_1_3-lib-linux-amd64-jdk.bin*
-rwxr-xr-x 1 ahc users 1684373 Oct 13  2006 jai_imageio-1_1-lib-linux-amd64-jdk.bin*
$ sed s/+215/-n+215/ jai_imageio-1_1-lib-linux-amd64-jdk.bin > jai_imageio-1_1-lib-linux-amd64-jdk_fixed.bin

Here is an edited sample describing the process to locate the exact location of the current Java executable. In this particular case the host is running AWS Linux and the required path is /usr/lib/jvm/jre-1.7.0-openjdk.x86_64

$ which java
$ ls -l /usr/bin/java
/usr/bin/java -> /etc/alternatives/java
$ ls -l /etc/alternatives/java
/etc/alternatives/java -> /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java

Move to the JAVA_HOME directory

Be sure to run the next step from the JAVA_HOME directory, or the installation will fail with an unrelated error message. This must be the directory at which the path to your current exact version of java is bin/java. The path to your java executable can contain several levels of indirection, so it is important to ensure you are working on the right version. The following example illustrates this test (note that paths will vary, and were determined by following the path of symbolic links starting with which java

$ pwd
$ java -version
java version "1.7.0_55"
$ bin/java -version
java version "1.7.0_55"

Run the installations

$ pwd
$ sudo ~/Downloads/jai-1_1_3-lib-linux-amd64-jdk.bin
$ sudo ~/Downloads/jai_imageio-1_1-lib-linux-amd64-jdk_fixed.bin

Java Upgrades

Upgrades of java will create a new directory path to the current executable. Since the JAI libraries are installed within the current path, upgrades may break JAI, requiring a repeat of the above process.