1 Java(tm) Binary Kernel Support for Linux v1.02 2 ---------------------------------------------- 3 4Linux beats them ALL! While all other OS's are TALKING about direct 5support of Java Binaries in the OS, Linux is doing it! 6 7You can execute Java applications and Java Applets just like any 8other program after you have done the following: 9 101) You MUST FIRST install the Java Developers Kit for Linux. 11 The Java on Linux HOWTO gives the details on getting and 12 installing this. This HOWTO can be found at: 13 14 ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO/Java-HOWTO 15 16 You should also set up a reasonable CLASSPATH environment 17 variable to use Java applications that make use of any 18 nonstandard classes (not included in the same directory 19 as the application itself). 20 212) You have to compile BINFMT_MISC either as a module or into 22 the kernel (CONFIG_BINFMT_MISC) and set it up properly. 23 If you choose to compile it as a module, you will have 24 to insert it manually with modprobe/insmod, as kerneld 25 can not easy be supported with binfmt_misc. 26 Read the file 'binfmt_misc.txt' in this directory to know 27 more about the configuration process. 28 293) Add the following configuration items to binfmt_misc 30 (you should really have read binfmt_misc.txt now): 31 support for Java applications: 32 ':Java:M::\xca\xfe\xba\xbe::/usr/local/java/bin/javawrapper:' 33 support for Java Applets: 34 ':Applet:E::html::/usr/local/java/bin/appletviewer:' 35 or the following, if you want to be more selective: 36 ':Applet:M::<!--applet::/usr/local/java/bin/appletviewer:' 37 38 Of cause you have to fix the path names, if you installed the JDK 39 at another place than /usr/local/java. 40 41 Note, that for the more selective applet support you have to modify 42 existing html-files to contain <!--applet--> in the first line 43 ('<' has to be the first character!) to let this work! 44 45 For the compiled Java programs you need a wrapper script like the 46 following (this is because Java is broken in case of the filename 47 handling), again fix the path names, both in the script and in the 48 above given configuration string: 49 50====================== Cut here =================== 51#!/bin/bash 52# /usr/local/java/bin/javawrapper - the wrapper for binfmt_misc/java 53CLASS=$1 54 55# if classname is a link, we follow it (this could be done easier - how?) 56if [ -L "$1" ] ; then 57 CLASS=`ls --color=no -l $1 | tr -s '\t ' ' ' | cut -d ' ' -f 11` 58fi 59CLASSN=`basename $CLASS .class` 60CLASSP=`dirname $CLASS` 61 62FOO=$PATH 63PATH=$CLASSPATH 64if [ -z "`type -p -a $CLASSN.class`" ] ; then 65 # class is not in CLASSPATH 66 if [ -e "$CLASSP/$CLASSN.class" ] ; then 67 # append dir of class to CLASSPATH 68 if [ -z "${CLASSPATH}" ] ; then 69 export CLASSPATH=$CLASSP 70 else 71 export CLASSPATH=$CLASSP:$CLASSPATH 72 fi 73 else 74 # uh! now we would have to create a symbolic link - really 75 # ugly, i.e. print a message that one has to change the setup 76 echo "Hey! This is not a good setup to run $1 !" 77 exit 1 78 fi 79fi 80PATH=$FOO 81 82shift 83/usr/local/java/bin/java $CLASSN "$@" 84====================== Cut here =================== 85 86 87Now simply chmod +x the .class and/or .html files you want to execute. 88To add a Java program to your path best put a symbolic link to the main 89.class file into /usr/bin (or another place you like) omitting the .class 90extension. The directory containing the original .class file will be 91added to your CLASSPATH during execution. 92 93 94To test your new setup, enter in the following simple Java app, and name 95it "HelloWorld.java": 96 97 class HelloWorld { 98 public static void main(String args[]) { 99 System.out.println("Hello World!"); 100 } 101 } 102 103Now compile the application with: 104 javac HelloWorld.java 105 106Set the executable permissions of the binary file, with: 107 chmod 755 HelloWorld.class 108 109And then execute it: 110 ./HelloWorld.class 111 112 113To execute Java Applets, simple chmod the *.html files to include 114the execution bit, then just do 115 ./Applet.html 116 117 118originally by Brian A. Lantz, brian@lantz.com 119heavily edited for binfmt_misc by Richard Günther. 120

