Java binary on Linux

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):

  • Recompile your kernel with CONFIG_BINFMT_MISC option. This can be achieved as follows:
    #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 and setup for Java executable:
    # 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
  • Now execute the following:
    # 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
  • 5. And now the fun part. Just chmod any Java class to execute it.
    # 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.

    Comment viewing options

    Select your preferred way to display the comments and click "Save settings" to activate your changes.
    Matt John Says:
    Sat, 2009-10-24 06:44

    Blackdown Java was a port of Sun Microsystems's Java virtual machine to Linux by a group of volunteers led by Karl Asha and Juergen Kreileder. It predated Sun's official Linux port, and supported Linux on architectures that the official version did not, including SPARC and PowerPC. At its close, Blackdown had released J2SE versions 1.4.2 on i386 and AMD64, 1.4.1 on SPARC, and 1.3.1 on PowerPC,ccnp certification Work on J2SE 1.5.x for x86, AMD64, SPARC, and PowerPC was noted as being underway, but no releases were apparent on the main website.

    Despite widespread confusion, Blackdown was neither free software nor open-source software. It was the default Java in Gentoo Linux and many other distributions, because the binary redistribution policy allowed it to be pre-installed or distributed through that distribution's package management system, whereas at the time, Sun Java's binary redistribution policy did not.

    Since Java 5, the Operating System Distributor License for Java (DLJ) meets many Linux distributions' requirements, so it is now the default for at least Gentoo Linux, unless you specify Java 1.4 or earlier, for which the DLJ does not apply.

    The Blackdown project ended in August 2007. The Java software itself still exists on many mirrors.

    amedeus1977 Says:
    Tue, 2010-07-27 02:53

    However, in order to realize the full potential of presence it will have to be relayed in a consistent manner, regardless of the network that the individual may be connected to. Doing this is going to require new products based on standards, and efforts to make that happen are underway now.Kingston
    Video Games
    Xbox
    Sony PSP

    davidhynes91 Says:
    Thu, 2011-03-03 10:05

    This is such a very interesting topic and I learn very something new about this topic. I know this is a hard thing to learn but we can still be able to achieve it.
    beco

    otisrobinson19 Says:
    Fri, 2011-03-11 10:19

    This is just perfect for my new blog! I have been meaning to find ways on how I can grab or create eye-candy twitter widgets like I find in most sites. So, this is exactly how it is done, thanks so much for sharing. The birdie btw, is really cute.
    kaldi.com

    patrickirwin79 Says:
    Tue, 2011-03-15 11:47

    The point that the data stated are all first hand on actual experiences even help more. Go on doing what you do as we enjoy reading your work.
    loan modification

    beats666 Says:
    Fri, 2011-04-29 05:43

    Beats Headphones are on Hot Sale NOW! High Quality, Competitive Price! Save Big on Monster Beats This Month Incredible Low Prices + Free Shipping & Fast Delivery. Sound is fashion, Monster Headphones are holistically designed to deliver the soundtrack of your life with clarity and power, as well as satisfy your passion for fashion. Do not hesitate to enjoy now!

    Post new comment


    *

    • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
    • Lines and paragraphs break automatically.