This feature will only be installed when Java is installed on Linux using the RPM packages. It will not be available when Java is installed from a tarball, or the self-extracting installer.
This feature will take advantage of the binfmt_misc capabilities that are integrated in the Linux kernel since version 2.4.13. binfmt_misc registers an interpreter with a particular file extension or magic number. More information on binfmt_misc is available on the website:
Java RPM packages will add the file /etc/init.d/jexec during the installation. Linux is similar to any System V Unix in that it uses links under the various rc[0-6].d directories to start and stop a service during system initialization. Unfortunately, no two Linux distributions seem to be quite alike in the final implementation of this. However, most distributions offer one or more tools to help in the installation of init scripts and the creation of the run level links.
The Java RPM packages will initially support the Red Hat, and Linux Standards Base (LSB) tools for installing and removing init scripts. Documentation from the web, and inspection of several lab systems shows the Red Hat tools are used on all version of Red Hat since at least RHEL AS 2.1, Fedora, and Debian. The LSB tools are used for all UnitedLinux/SuSE derived distributions, including the Java Desktop System (JDS).
Each tool set basically works in the same way. Once an init script is dropped into /etc/init, the tool is invoked, which uses special comments in the init script to create the appropriate run level links, automatically assigning an appropriate S[0-9][0-9] or K[0-9][0-9] prefix. During uninstall, another tool is used to remove these links. The Java RPM packages will never create any of these links directly.
The Java RPM packages will include an init script that contains the necessary comments to support both the LSB and Red Hat tools. The script will contain logic to start/stop the binfmt_misc service, and register the interpreter for the JAR binary type. The package's post-install scriptlet will contain logic to determine which if any tool set is available. If the LSB or Red Hat tool set is detected, it will be invoked, installing the proper run level links, and then the init script itself is started. If neither tool sets is detected, the init script will not be registered.
By default, the Java RPM packages will register the jexec to start in run levels 1, 2, 3, 4, and 5. (These are all the interactive run levels on Linux.) Once registered, most, if not all Linux distributions provide CLI and GUI tools that allow a privileged user to change what run levels a service is started or stopped in.
Note: Unlike Solaris, it is necessary under Linux to register a start link for a run level, even when a previous run level has already started the service. For example, on Solaris an entry in rc2.d would imply the service also is started in run level 3. However, Linux requires entries in both.
The /etc/init.d/jexec file will handle the start and stop commands. The start command will initialize the binfmt_misc virtual file system, and register the interpreter for the JAR binary type. Initialization of binfmt_misc occurs as follows:
1) if the file /proc/sys/fs/binfmt_misc/register already exists, then initialization is complete
2) if the directory /proc/sys/fs/binfmt_misc does not exist, then binfmt_misc is not supported on the system, initialization is complete, and there is nothing to register
3) mount binfmt_misc to /proc, as in:
mount -t binfmt_misc none /proc/sys/fs/binfmt_misc
4) if the file /proc/sys/fs/binfmt_misc/register does not exist, then binfmt_misc initialization failed, and there is nothing to register
Registration of the JAR binary interpreter occurs as follows:
1) if the file /proc/sys/fs/binfmt_misc/jexec already exists, then something has already been registered in the namespace
2) with the exception of the files 'register' and 'status', ensure each file in /proc/sys/fs/binfmt_misc does not contain the PK-Zip magic number; if any file already contains this number, something has already been registered
3) register the jexec interpreter for the PK-Zip magic number using the following command:
echo ':jarexec:M::PK\x03\x04::/usr/java/default/lib/jexec:' \
The jexec program is a simple launcher. It's main purpose is the verify that the PK-ZIP file detected by binfmt_misc is actually a JAR file. This is necessary because binfmt_misc is limited to detecting a files magic number in a static location within the first 127 bytes of the file. Unfortunately the location of the JAR magic number is not static, or even garunteed to be in the first 127 bytes of the file. The Jar magic number is stored in one of the members of extra field data list in the local file header of the first file.
###@###.### 2005-05-27 20:30:45 GMT