Recently noticed support for Java binary on Linux kernel which means you can execute your Java applications simply as:
$ ./HelloWorld.class
And this can be achieved in following few steps(Assuming JDK is already installed and CLASSPATH properly configured):
#cd /usr/src/linux; make menuconfig
Select "Executable file formats / Emulations" -> Kernel Support for MISC binaries
Save and exit. Follow /usr/src/linux/README for further information on compiling the kernel.
BINFMT_MISC can also be compiled as a independent module and inserted manually. This feature allows you to invoke almost any binary by simply typing it's name in shell. Refer to /usr/src/linux/Documentation/binfmt_misc.txt for more information on this.
# mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
# echo ':Java:M::\xca\xfe\xba\xbe::/usr/local/bin/javawrapper:' > /proc/sys/fs/binfmt_misc/register
# cat /usr/src/linux/Documentation/java.txt |grep -m3 -A 195 "Cut here"
and copy the first script as /usr/local/bin/javawrapper. This script will add the class file to classpath.
Compile the second C program as follow:
# gcc -O2 -o javaclassname javaclassname.c
# cp javaclassname /usr/local/bin
This executable is required to find the fully qualified class name i.e. for class Test.class in package foo.bar, it will return foo.bar.Test
# javac HelloWorld.java
# chmod +x HelloWorld.class
# ./HelloWorld.class
I gathered this from /usr/src/linux/Documentation/java.txt which can be referred for more information.
