Java Technology Home Page

Advanced Search

Java Technology Home Page
Technologies
- J2EE
- J2SE
- J2ME
- Java Card
- Web Services
- Wireless
- XML
- Other
Downloads
- Early Access
Documentation
- APIs
- Tutorials
- Code Samples
- See All
Industry News
Developer Services
- Bug Database
- Forums
- Support
- See All
Java BluePrints
    Printable Page  Printable Page

Tutorial Index

Java Advanced Imaging Tutorial

Overview |  Tutorial

The Java Advanced Imaging (JAI) tutorial provides an overview of JAI features, source code, and demos in the form of an interactive book. Examples show key JAI functionality and coding style to incorporate advanced imaging features into programs or applets, including:

  • Convolution filtering
  • Basic image arithmetic operators
  • Look up table operations (brightness and contrast)
  • Pan and zoom
  • Image compositing

The tutorial was written using the Java Foundation Classes and Project Swing components. To view this tutorial or to develop applets using JAI, you must download and install the Java Plug-In and the JAI package. This tutorial is also available in application form on the JAI web site.

Tutorial Set Up

To view JAI tutorial applets in your browser:

  1. Download and install the latest version of Java Plug-In.
  2. Download and install the latest version of JAI. The JAI installation puts the files into the JDK on the system. To use JAI with applets in browsers, copy the appropriate JAR files to the virtual machine used by the browser.

For Solaris

The next steps assume that Netscape has been installed in the following path:

/opt/NSCPcom/
  1. Set the following environment variables (in csh):

      % setenv THREADS_FLAG native 
      % setenv NPX_PLUGIN_PATH /opt/NSCPcom/plugins
      % setenv NPX_JRE_PATH /opt/NSCPcom/j2pi
    
  2. Copy the JAI files to the plugin directory:

    $PLUGIN is the location Netscape has been installed.

    $ARCH is the architecture(sparc/i386).
    $JAVAHOME is the location of the JDK.
     
      // Type each %cp command on one line
      
      %cp $JAVAHOME/jre/lib/ext/jai_core.jar $PLUGIN
                                            /j2pi/lib/
      %cp $JAVAHOME/jre/lib/ext/jai_codec.jar 
                                    $PLUGIN/j2pi/lib/
      %cp $JAVAHOME/jre/lib/ext/mlibwrapper_jai.jar 
                                    $PLUGIN/j2pi/lib/
      %cp $JAVAHOME/jre/lib/ext/registryFile.jai 
                                    $PLUGIN/j2pi/lib/
    
      %cp $JAVAHOME/jre/lib/$ARCH/libmlib_java_jai.so 
                              $PLUGIN/j2pi/lib/$ARCH/
    
  3. If $ARCH is sparc, do the following:
     // Type the following on one line
     
     %cp $JAVAHOME/jre/lib/$ARCH
                  /libmlib_java_jai_vis.so 
                           $PLUGIN/j2pi/lib/$ARCH/
    

For Windows

Copy the JAI files to the JRE in the JavaSoft directory.

C:\Program Files\JavaSoft\JRE\

Copying the files can be done either from the command line or from Windows Explorer.

  1. From the command line:

    %JAVAHOME% is the location of the JDK.
    %JRE% is the location of the Java Runtime Environment.

      
    ()
    
      // Type each of the commands on one line
      
      C:\>copy %JAVAHOME%\jre\lib\ext
                      \jai_core.jar %JRE%\lib\ext
      C:\>copy %JAVAHOME%\jre\lib\ext
                     \jai_codec.jar %JRE%\lib\ext
      C:\>copy %JAVAHOME%\jre\lib\ext
               \mlibwrapper_jai.jar %JRE%\lib\ext
      C:\>copy %JAVAHOME%\jre\lib\ext
                  \registryFile.jai %JRE%\lib\ext
      C:\>copy %JAVAHOME%\jre\bin\
                     mlib_image_jai.dll %JRE%\bin\
      C:\>copy %JAVAHOME%\jre\bin
                     \mlib_java_jai.dll %JRE%\bin\
    
  2. From Windows Explorer:

    Copy and paste the files from
     \lib\ext
     
    to:
       C:\Program Files\JavaSoft\JRE\
       
    In addition, copy and paste the files in
        \bin\
        
    to:
         C:\Program Files\JavaSoft\JRE\
         

These steps ensure that the JAI files are picked up by the plugin at runtime.

Applet Permissions

For JAI applets to use native acceleration on the Sparc and Windows platforms, appropriate security permissions must be given.

Edit the java.policy file to set permissions. The location of java.policy depends on your operating system.

  • Solaris:

    /opt/NSCPcom/j2pi/lib/security/java.policy
  • Windows:

    C:\Program Files\JavaSoft\Jre\1.x\lib\security\java.policy

    Edit java.policy so it contains only the following:
    grant 
    {
        permission java.security.AllPermission;
    };
    

Warning: Setting these security permissions grants ALL applets complete privileges on your system, which may expose your system to danger from rogue applets.

Note: In case an OutOfMemoryException is encountered while running some of the demos in the tutorial, try changing the amount of memory available to the Java Virtual Machine1 by adding the following "Java Run Time Parameters" in the Java Plug In Control Panel:

-ms16m -mx64m

The Java Plug In Control Panel is located in the Control Panel on Windows machine and in the Java Plug In directory on Solaris machines (typically /opt/NSCPcom/j2pi)

Overview |  Tutorial

Reader Survey

Tell us what you think of this tutorial.

[Duke]

Very worth reading Worth reading Not worth reading

If you have other comments or ideas for future articles, please type them here:

_______
1 As used on this web site, the terms "Java Virtual Machine" or "JVM" mean a virtual machine for the Java platform.


[ This page was last updated Mar-22-2003 ]

Company Info | Licensing | Employment | Press | Contact |   XML
JavaOne | Java Community Process | Java Wear and Books | Content Feeds | Java Series Books

Java, J2EE, J2SE, J2ME, and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.
 
 
Unless otherwise licensed, code in all
technical manuals herein (including articles,
FAQs, samples) is provided under this License.

Sun Microsystems, Inc.

Copyright © 1995-2003 Sun Microsystems, Inc.
All Rights Reserved. Terms of Use. Privacy Policy. Trademarks.