Contents

Introduction

"binfmt_misc is a capability of the Linux kernel which allows arbitrary executable file formats to be recognized and passed to certain user space applications, such as emulators and virtual machines."

In plain language, this allows you to take a Java jar file that you would ordinarily run via a line such as

java -jar /path/to/MyProgram.jar

and instead run it simply with

MyProgram.jar

as long as it's on the PATH.

The information in this article is almost entirely taken from the files binfmt_misc.txt and java.txt in the Documentation sub-directory of the Linux kernel source tree.

Setup

Mounting binfmt_misc

For an ad-hoc mount:

mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc

For a persistent mount via fstab add the line:

none /proc/sys/fs/binfmt_misc binfmt_misc defaults 0 0

Registering the file type with binfmt_misc

This is done by echoing a specially formatted line to /proc/sys/fs/binfmt_misc/register. The contents of the line is explained in the Documentation/binfmt_misc.txt file. To make the file registrations automatic at boot you can add the appropriate lines to your rc.local file, for example:

The first two of the above entries run Java class and jar files via 'wrapper' scripts describe in the next section. The final entry runs Java applets in the usual way. You may reboot or run the file to put the registrations into effect immediately.