Installing Java extensions

Extensions are packages of Java™ classes that you can use to extend the functionality of the core platform. Extensions are packaged in one or more ZIP files or JAR files, and are loaded into the Java virtual machine by an extension class loader.

The extension mechanism allows the Java virtual machine to use the extension classes in the same way that the virtual machine uses the system classes. The extension mechanism also provides a way for you to retrieve extensions from specified Uniform Resource Locators (URLs) when they are not already installed in the Java 2 Platform, Standard Edition (J2SE).

Some JAR files for extensions are shipped with IBM® i. If you would like to install one of these extensions, enter this command:


ADDLNK OBJ('/QIBM/ProdData/Java400/ext/extensionToInstall.jar')
     NEWLNK('/QIBM/UserData/Java400/ext/extensionToInstall.jar')
     LNKTYPE(*SYMBOLIC)

Where

extensionToInstall.jar

is the name of the ZIP or JAR file that contains the extension that you want to install.

Note: JAR files of extensions not provided by IBM may be placed in the /QIBM/UserData/Java400/ext directory.

When you create a link or add a file to an extension in the /QIBM/UserData/Java400/ext directory, the list of files that the extension class loader searches changes for every Java virtual machine that is running on your server. If you do not want to impact the extension class loaders for other Java virtual machines on your server, but you still want to create a link to an extension or install an extension not shipped by IBM with the server, follow these steps:

  1. Create a directory to install the extensions. Use either the Make Directory (MKDIR) command from the IBM i command line or the mkdir command from the Qshell Interpreter.
  2. Place the extension JAR file in the directory created.
  3. Add the new directory to the java.ext.dirs property. You can add the new directory to the java.ext.dirs property by using the PROP field of the JAVA command from the IBM i command line.

If the name of your new directory is /home/username/ext, the name of your extension file is extensionToInstall.jar, and the name of your Java program is Hello, then the commands that you enter should look like this:


MKDIR DIR('/home/username/ext')

CPY OBJ('/productA/extensionToInstall.jar') TODIR('/home/username/ext') or 
copy the file to /home/username/ext using FTP (file transfer protocol).

JAVA Hello PROP((java.ext.dirs '/home/username/ext'))