1*4882a593SmuzhiyunJava(tm) Binary Kernel Support for Linux v1.03 2*4882a593Smuzhiyun---------------------------------------------- 3*4882a593Smuzhiyun 4*4882a593SmuzhiyunLinux beats them ALL! While all other OS's are TALKING about direct 5*4882a593Smuzhiyunsupport of Java Binaries in the OS, Linux is doing it! 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunYou can execute Java applications and Java Applets just like any 8*4882a593Smuzhiyunother program after you have done the following: 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun1) You MUST FIRST install the Java Developers Kit for Linux. 11*4882a593Smuzhiyun The Java on Linux HOWTO gives the details on getting and 12*4882a593Smuzhiyun installing this. This HOWTO can be found at: 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun ftp://sunsite.unc.edu/pub/Linux/docs/HOWTO/Java-HOWTO 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun You should also set up a reasonable CLASSPATH environment 17*4882a593Smuzhiyun variable to use Java applications that make use of any 18*4882a593Smuzhiyun nonstandard classes (not included in the same directory 19*4882a593Smuzhiyun as the application itself). 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun2) You have to compile BINFMT_MISC either as a module or into 22*4882a593Smuzhiyun the kernel (``CONFIG_BINFMT_MISC``) and set it up properly. 23*4882a593Smuzhiyun If you choose to compile it as a module, you will have 24*4882a593Smuzhiyun to insert it manually with modprobe/insmod, as kmod 25*4882a593Smuzhiyun cannot easily be supported with binfmt_misc. 26*4882a593Smuzhiyun Read the file 'binfmt_misc.txt' in this directory to know 27*4882a593Smuzhiyun more about the configuration process. 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun3) Add the following configuration items to binfmt_misc 30*4882a593Smuzhiyun (you should really have read ``binfmt_misc.txt`` now): 31*4882a593Smuzhiyun support for Java applications:: 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun ':Java:M::\xca\xfe\xba\xbe::/usr/local/bin/javawrapper:' 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun support for executable Jar files:: 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun ':ExecutableJAR:E::jar::/usr/local/bin/jarwrapper:' 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun support for Java Applets:: 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun ':Applet:E::html::/usr/bin/appletviewer:' 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun or the following, if you want to be more selective:: 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun ':Applet:M::<!--applet::/usr/bin/appletviewer:' 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun Of course you have to fix the path names. The path/file names given in this 48*4882a593Smuzhiyun document match the Debian 2.1 system. (i.e. jdk installed in ``/usr``, 49*4882a593Smuzhiyun custom wrappers from this document in ``/usr/local``) 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun Note, that for the more selective applet support you have to modify 52*4882a593Smuzhiyun existing html-files to contain ``<!--applet-->`` in the first line 53*4882a593Smuzhiyun (``<`` has to be the first character!) to let this work! 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun For the compiled Java programs you need a wrapper script like the 56*4882a593Smuzhiyun following (this is because Java is broken in case of the filename 57*4882a593Smuzhiyun handling), again fix the path names, both in the script and in the 58*4882a593Smuzhiyun above given configuration string. 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun You, too, need the little program after the script. Compile like:: 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun gcc -O2 -o javaclassname javaclassname.c 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun and stick it to ``/usr/local/bin``. 65*4882a593Smuzhiyun 66*4882a593Smuzhiyun Both the javawrapper shellscript and the javaclassname program 67*4882a593Smuzhiyun were supplied by Colin J. Watson <cjw44@cam.ac.uk>. 68*4882a593Smuzhiyun 69*4882a593SmuzhiyunJavawrapper shell script: 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun.. code-block:: sh 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun #!/bin/bash 74*4882a593Smuzhiyun # /usr/local/bin/javawrapper - the wrapper for binfmt_misc/java 75*4882a593Smuzhiyun 76*4882a593Smuzhiyun if [ -z "$1" ]; then 77*4882a593Smuzhiyun exec 1>&2 78*4882a593Smuzhiyun echo Usage: $0 class-file 79*4882a593Smuzhiyun exit 1 80*4882a593Smuzhiyun fi 81*4882a593Smuzhiyun 82*4882a593Smuzhiyun CLASS=$1 83*4882a593Smuzhiyun FQCLASS=`/usr/local/bin/javaclassname $1` 84*4882a593Smuzhiyun FQCLASSN=`echo $FQCLASS | sed -e 's/^.*\.\([^.]*\)$/\1/'` 85*4882a593Smuzhiyun FQCLASSP=`echo $FQCLASS | sed -e 's-\.-/-g' -e 's-^[^/]*$--' -e 's-/[^/]*$--'` 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun # for example: 88*4882a593Smuzhiyun # CLASS=Test.class 89*4882a593Smuzhiyun # FQCLASS=foo.bar.Test 90*4882a593Smuzhiyun # FQCLASSN=Test 91*4882a593Smuzhiyun # FQCLASSP=foo/bar 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun unset CLASSBASE 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun declare -i LINKLEVEL=0 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun while :; do 98*4882a593Smuzhiyun if [ "`basename $CLASS .class`" == "$FQCLASSN" ]; then 99*4882a593Smuzhiyun # See if this directory works straight off 100*4882a593Smuzhiyun cd -L `dirname $CLASS` 101*4882a593Smuzhiyun CLASSDIR=$PWD 102*4882a593Smuzhiyun cd $OLDPWD 103*4882a593Smuzhiyun if echo $CLASSDIR | grep -q "$FQCLASSP$"; then 104*4882a593Smuzhiyun CLASSBASE=`echo $CLASSDIR | sed -e "s.$FQCLASSP$.."` 105*4882a593Smuzhiyun break; 106*4882a593Smuzhiyun fi 107*4882a593Smuzhiyun # Try dereferencing the directory name 108*4882a593Smuzhiyun cd -P `dirname $CLASS` 109*4882a593Smuzhiyun CLASSDIR=$PWD 110*4882a593Smuzhiyun cd $OLDPWD 111*4882a593Smuzhiyun if echo $CLASSDIR | grep -q "$FQCLASSP$"; then 112*4882a593Smuzhiyun CLASSBASE=`echo $CLASSDIR | sed -e "s.$FQCLASSP$.."` 113*4882a593Smuzhiyun break; 114*4882a593Smuzhiyun fi 115*4882a593Smuzhiyun # If no other possible filename exists 116*4882a593Smuzhiyun if [ ! -L $CLASS ]; then 117*4882a593Smuzhiyun exec 1>&2 118*4882a593Smuzhiyun echo $0: 119*4882a593Smuzhiyun echo " $CLASS should be in a" \ 120*4882a593Smuzhiyun "directory tree called $FQCLASSP" 121*4882a593Smuzhiyun exit 1 122*4882a593Smuzhiyun fi 123*4882a593Smuzhiyun fi 124*4882a593Smuzhiyun if [ ! -L $CLASS ]; then break; fi 125*4882a593Smuzhiyun # Go down one more level of symbolic links 126*4882a593Smuzhiyun let LINKLEVEL+=1 127*4882a593Smuzhiyun if [ $LINKLEVEL -gt 5 ]; then 128*4882a593Smuzhiyun exec 1>&2 129*4882a593Smuzhiyun echo $0: 130*4882a593Smuzhiyun echo " Too many symbolic links encountered" 131*4882a593Smuzhiyun exit 1 132*4882a593Smuzhiyun fi 133*4882a593Smuzhiyun CLASS=`ls --color=no -l $CLASS | sed -e 's/^.* \([^ ]*\)$/\1/'` 134*4882a593Smuzhiyun done 135*4882a593Smuzhiyun 136*4882a593Smuzhiyun if [ -z "$CLASSBASE" ]; then 137*4882a593Smuzhiyun if [ -z "$FQCLASSP" ]; then 138*4882a593Smuzhiyun GOODNAME=$FQCLASSN.class 139*4882a593Smuzhiyun else 140*4882a593Smuzhiyun GOODNAME=$FQCLASSP/$FQCLASSN.class 141*4882a593Smuzhiyun fi 142*4882a593Smuzhiyun exec 1>&2 143*4882a593Smuzhiyun echo $0: 144*4882a593Smuzhiyun echo " $FQCLASS should be in a file called $GOODNAME" 145*4882a593Smuzhiyun exit 1 146*4882a593Smuzhiyun fi 147*4882a593Smuzhiyun 148*4882a593Smuzhiyun if ! echo $CLASSPATH | grep -q "^\(.*:\)*$CLASSBASE\(:.*\)*"; then 149*4882a593Smuzhiyun # class is not in CLASSPATH, so prepend dir of class to CLASSPATH 150*4882a593Smuzhiyun if [ -z "${CLASSPATH}" ] ; then 151*4882a593Smuzhiyun export CLASSPATH=$CLASSBASE 152*4882a593Smuzhiyun else 153*4882a593Smuzhiyun export CLASSPATH=$CLASSBASE:$CLASSPATH 154*4882a593Smuzhiyun fi 155*4882a593Smuzhiyun fi 156*4882a593Smuzhiyun 157*4882a593Smuzhiyun shift 158*4882a593Smuzhiyun /usr/bin/java $FQCLASS "$@" 159*4882a593Smuzhiyun 160*4882a593Smuzhiyunjavaclassname.c: 161*4882a593Smuzhiyun 162*4882a593Smuzhiyun.. code-block:: c 163*4882a593Smuzhiyun 164*4882a593Smuzhiyun /* javaclassname.c 165*4882a593Smuzhiyun * 166*4882a593Smuzhiyun * Extracts the class name from a Java class file; intended for use in a Java 167*4882a593Smuzhiyun * wrapper of the type supported by the binfmt_misc option in the Linux kernel. 168*4882a593Smuzhiyun * 169*4882a593Smuzhiyun * Copyright (C) 1999 Colin J. Watson <cjw44@cam.ac.uk>. 170*4882a593Smuzhiyun * 171*4882a593Smuzhiyun * This program is free software; you can redistribute it and/or modify 172*4882a593Smuzhiyun * it under the terms of the GNU General Public License as published by 173*4882a593Smuzhiyun * the Free Software Foundation; either version 2 of the License, or 174*4882a593Smuzhiyun * (at your option) any later version. 175*4882a593Smuzhiyun * 176*4882a593Smuzhiyun * This program is distributed in the hope that it will be useful, 177*4882a593Smuzhiyun * but WITHOUT ANY WARRANTY; without even the implied warranty of 178*4882a593Smuzhiyun * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 179*4882a593Smuzhiyun * GNU General Public License for more details. 180*4882a593Smuzhiyun * 181*4882a593Smuzhiyun * You should have received a copy of the GNU General Public License 182*4882a593Smuzhiyun * along with this program; if not, write to the Free Software 183*4882a593Smuzhiyun * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 184*4882a593Smuzhiyun */ 185*4882a593Smuzhiyun 186*4882a593Smuzhiyun #include <stdlib.h> 187*4882a593Smuzhiyun #include <stdio.h> 188*4882a593Smuzhiyun #include <stdarg.h> 189*4882a593Smuzhiyun #include <sys/types.h> 190*4882a593Smuzhiyun 191*4882a593Smuzhiyun /* From Sun's Java VM Specification, as tag entries in the constant pool. */ 192*4882a593Smuzhiyun 193*4882a593Smuzhiyun #define CP_UTF8 1 194*4882a593Smuzhiyun #define CP_INTEGER 3 195*4882a593Smuzhiyun #define CP_FLOAT 4 196*4882a593Smuzhiyun #define CP_LONG 5 197*4882a593Smuzhiyun #define CP_DOUBLE 6 198*4882a593Smuzhiyun #define CP_CLASS 7 199*4882a593Smuzhiyun #define CP_STRING 8 200*4882a593Smuzhiyun #define CP_FIELDREF 9 201*4882a593Smuzhiyun #define CP_METHODREF 10 202*4882a593Smuzhiyun #define CP_INTERFACEMETHODREF 11 203*4882a593Smuzhiyun #define CP_NAMEANDTYPE 12 204*4882a593Smuzhiyun #define CP_METHODHANDLE 15 205*4882a593Smuzhiyun #define CP_METHODTYPE 16 206*4882a593Smuzhiyun #define CP_INVOKEDYNAMIC 18 207*4882a593Smuzhiyun 208*4882a593Smuzhiyun /* Define some commonly used error messages */ 209*4882a593Smuzhiyun 210*4882a593Smuzhiyun #define seek_error() error("%s: Cannot seek\n", program) 211*4882a593Smuzhiyun #define corrupt_error() error("%s: Class file corrupt\n", program) 212*4882a593Smuzhiyun #define eof_error() error("%s: Unexpected end of file\n", program) 213*4882a593Smuzhiyun #define utf8_error() error("%s: Only ASCII 1-255 supported\n", program); 214*4882a593Smuzhiyun 215*4882a593Smuzhiyun char *program; 216*4882a593Smuzhiyun 217*4882a593Smuzhiyun long *pool; 218*4882a593Smuzhiyun 219*4882a593Smuzhiyun u_int8_t read_8(FILE *classfile); 220*4882a593Smuzhiyun u_int16_t read_16(FILE *classfile); 221*4882a593Smuzhiyun void skip_constant(FILE *classfile, u_int16_t *cur); 222*4882a593Smuzhiyun void error(const char *format, ...); 223*4882a593Smuzhiyun int main(int argc, char **argv); 224*4882a593Smuzhiyun 225*4882a593Smuzhiyun /* Reads in an unsigned 8-bit integer. */ 226*4882a593Smuzhiyun u_int8_t read_8(FILE *classfile) 227*4882a593Smuzhiyun { 228*4882a593Smuzhiyun int b = fgetc(classfile); 229*4882a593Smuzhiyun if(b == EOF) 230*4882a593Smuzhiyun eof_error(); 231*4882a593Smuzhiyun return (u_int8_t)b; 232*4882a593Smuzhiyun } 233*4882a593Smuzhiyun 234*4882a593Smuzhiyun /* Reads in an unsigned 16-bit integer. */ 235*4882a593Smuzhiyun u_int16_t read_16(FILE *classfile) 236*4882a593Smuzhiyun { 237*4882a593Smuzhiyun int b1, b2; 238*4882a593Smuzhiyun b1 = fgetc(classfile); 239*4882a593Smuzhiyun if(b1 == EOF) 240*4882a593Smuzhiyun eof_error(); 241*4882a593Smuzhiyun b2 = fgetc(classfile); 242*4882a593Smuzhiyun if(b2 == EOF) 243*4882a593Smuzhiyun eof_error(); 244*4882a593Smuzhiyun return (u_int16_t)((b1 << 8) | b2); 245*4882a593Smuzhiyun } 246*4882a593Smuzhiyun 247*4882a593Smuzhiyun /* Reads in a value from the constant pool. */ 248*4882a593Smuzhiyun void skip_constant(FILE *classfile, u_int16_t *cur) 249*4882a593Smuzhiyun { 250*4882a593Smuzhiyun u_int16_t len; 251*4882a593Smuzhiyun int seekerr = 1; 252*4882a593Smuzhiyun pool[*cur] = ftell(classfile); 253*4882a593Smuzhiyun switch(read_8(classfile)) 254*4882a593Smuzhiyun { 255*4882a593Smuzhiyun case CP_UTF8: 256*4882a593Smuzhiyun len = read_16(classfile); 257*4882a593Smuzhiyun seekerr = fseek(classfile, len, SEEK_CUR); 258*4882a593Smuzhiyun break; 259*4882a593Smuzhiyun case CP_CLASS: 260*4882a593Smuzhiyun case CP_STRING: 261*4882a593Smuzhiyun case CP_METHODTYPE: 262*4882a593Smuzhiyun seekerr = fseek(classfile, 2, SEEK_CUR); 263*4882a593Smuzhiyun break; 264*4882a593Smuzhiyun case CP_METHODHANDLE: 265*4882a593Smuzhiyun seekerr = fseek(classfile, 3, SEEK_CUR); 266*4882a593Smuzhiyun break; 267*4882a593Smuzhiyun case CP_INTEGER: 268*4882a593Smuzhiyun case CP_FLOAT: 269*4882a593Smuzhiyun case CP_FIELDREF: 270*4882a593Smuzhiyun case CP_METHODREF: 271*4882a593Smuzhiyun case CP_INTERFACEMETHODREF: 272*4882a593Smuzhiyun case CP_NAMEANDTYPE: 273*4882a593Smuzhiyun case CP_INVOKEDYNAMIC: 274*4882a593Smuzhiyun seekerr = fseek(classfile, 4, SEEK_CUR); 275*4882a593Smuzhiyun break; 276*4882a593Smuzhiyun case CP_LONG: 277*4882a593Smuzhiyun case CP_DOUBLE: 278*4882a593Smuzhiyun seekerr = fseek(classfile, 8, SEEK_CUR); 279*4882a593Smuzhiyun ++(*cur); 280*4882a593Smuzhiyun break; 281*4882a593Smuzhiyun default: 282*4882a593Smuzhiyun corrupt_error(); 283*4882a593Smuzhiyun } 284*4882a593Smuzhiyun if(seekerr) 285*4882a593Smuzhiyun seek_error(); 286*4882a593Smuzhiyun } 287*4882a593Smuzhiyun 288*4882a593Smuzhiyun void error(const char *format, ...) 289*4882a593Smuzhiyun { 290*4882a593Smuzhiyun va_list ap; 291*4882a593Smuzhiyun va_start(ap, format); 292*4882a593Smuzhiyun vfprintf(stderr, format, ap); 293*4882a593Smuzhiyun va_end(ap); 294*4882a593Smuzhiyun exit(1); 295*4882a593Smuzhiyun } 296*4882a593Smuzhiyun 297*4882a593Smuzhiyun int main(int argc, char **argv) 298*4882a593Smuzhiyun { 299*4882a593Smuzhiyun FILE *classfile; 300*4882a593Smuzhiyun u_int16_t cp_count, i, this_class, classinfo_ptr; 301*4882a593Smuzhiyun u_int8_t length; 302*4882a593Smuzhiyun 303*4882a593Smuzhiyun program = argv[0]; 304*4882a593Smuzhiyun 305*4882a593Smuzhiyun if(!argv[1]) 306*4882a593Smuzhiyun error("%s: Missing input file\n", program); 307*4882a593Smuzhiyun classfile = fopen(argv[1], "rb"); 308*4882a593Smuzhiyun if(!classfile) 309*4882a593Smuzhiyun error("%s: Error opening %s\n", program, argv[1]); 310*4882a593Smuzhiyun 311*4882a593Smuzhiyun if(fseek(classfile, 8, SEEK_SET)) /* skip magic and version numbers */ 312*4882a593Smuzhiyun seek_error(); 313*4882a593Smuzhiyun cp_count = read_16(classfile); 314*4882a593Smuzhiyun pool = calloc(cp_count, sizeof(long)); 315*4882a593Smuzhiyun if(!pool) 316*4882a593Smuzhiyun error("%s: Out of memory for constant pool\n", program); 317*4882a593Smuzhiyun 318*4882a593Smuzhiyun for(i = 1; i < cp_count; ++i) 319*4882a593Smuzhiyun skip_constant(classfile, &i); 320*4882a593Smuzhiyun if(fseek(classfile, 2, SEEK_CUR)) /* skip access flags */ 321*4882a593Smuzhiyun seek_error(); 322*4882a593Smuzhiyun 323*4882a593Smuzhiyun this_class = read_16(classfile); 324*4882a593Smuzhiyun if(this_class < 1 || this_class >= cp_count) 325*4882a593Smuzhiyun corrupt_error(); 326*4882a593Smuzhiyun if(!pool[this_class] || pool[this_class] == -1) 327*4882a593Smuzhiyun corrupt_error(); 328*4882a593Smuzhiyun if(fseek(classfile, pool[this_class] + 1, SEEK_SET)) 329*4882a593Smuzhiyun seek_error(); 330*4882a593Smuzhiyun 331*4882a593Smuzhiyun classinfo_ptr = read_16(classfile); 332*4882a593Smuzhiyun if(classinfo_ptr < 1 || classinfo_ptr >= cp_count) 333*4882a593Smuzhiyun corrupt_error(); 334*4882a593Smuzhiyun if(!pool[classinfo_ptr] || pool[classinfo_ptr] == -1) 335*4882a593Smuzhiyun corrupt_error(); 336*4882a593Smuzhiyun if(fseek(classfile, pool[classinfo_ptr] + 1, SEEK_SET)) 337*4882a593Smuzhiyun seek_error(); 338*4882a593Smuzhiyun 339*4882a593Smuzhiyun length = read_16(classfile); 340*4882a593Smuzhiyun for(i = 0; i < length; ++i) 341*4882a593Smuzhiyun { 342*4882a593Smuzhiyun u_int8_t x = read_8(classfile); 343*4882a593Smuzhiyun if((x & 0x80) || !x) 344*4882a593Smuzhiyun { 345*4882a593Smuzhiyun if((x & 0xE0) == 0xC0) 346*4882a593Smuzhiyun { 347*4882a593Smuzhiyun u_int8_t y = read_8(classfile); 348*4882a593Smuzhiyun if((y & 0xC0) == 0x80) 349*4882a593Smuzhiyun { 350*4882a593Smuzhiyun int c = ((x & 0x1f) << 6) + (y & 0x3f); 351*4882a593Smuzhiyun if(c) putchar(c); 352*4882a593Smuzhiyun else utf8_error(); 353*4882a593Smuzhiyun } 354*4882a593Smuzhiyun else utf8_error(); 355*4882a593Smuzhiyun } 356*4882a593Smuzhiyun else utf8_error(); 357*4882a593Smuzhiyun } 358*4882a593Smuzhiyun else if(x == '/') putchar('.'); 359*4882a593Smuzhiyun else putchar(x); 360*4882a593Smuzhiyun } 361*4882a593Smuzhiyun putchar('\n'); 362*4882a593Smuzhiyun free(pool); 363*4882a593Smuzhiyun fclose(classfile); 364*4882a593Smuzhiyun return 0; 365*4882a593Smuzhiyun } 366*4882a593Smuzhiyun 367*4882a593Smuzhiyunjarwrapper:: 368*4882a593Smuzhiyun 369*4882a593Smuzhiyun #!/bin/bash 370*4882a593Smuzhiyun # /usr/local/java/bin/jarwrapper - the wrapper for binfmt_misc/jar 371*4882a593Smuzhiyun 372*4882a593Smuzhiyun java -jar $1 373*4882a593Smuzhiyun 374*4882a593Smuzhiyun 375*4882a593SmuzhiyunNow simply ``chmod +x`` the ``.class``, ``.jar`` and/or ``.html`` files you 376*4882a593Smuzhiyunwant to execute. 377*4882a593Smuzhiyun 378*4882a593SmuzhiyunTo add a Java program to your path best put a symbolic link to the main 379*4882a593Smuzhiyun.class file into /usr/bin (or another place you like) omitting the .class 380*4882a593Smuzhiyunextension. The directory containing the original .class file will be 381*4882a593Smuzhiyunadded to your CLASSPATH during execution. 382*4882a593Smuzhiyun 383*4882a593Smuzhiyun 384*4882a593SmuzhiyunTo test your new setup, enter in the following simple Java app, and name 385*4882a593Smuzhiyunit "HelloWorld.java": 386*4882a593Smuzhiyun 387*4882a593Smuzhiyun.. code-block:: java 388*4882a593Smuzhiyun 389*4882a593Smuzhiyun class HelloWorld { 390*4882a593Smuzhiyun public static void main(String args[]) { 391*4882a593Smuzhiyun System.out.println("Hello World!"); 392*4882a593Smuzhiyun } 393*4882a593Smuzhiyun } 394*4882a593Smuzhiyun 395*4882a593SmuzhiyunNow compile the application with:: 396*4882a593Smuzhiyun 397*4882a593Smuzhiyun javac HelloWorld.java 398*4882a593Smuzhiyun 399*4882a593SmuzhiyunSet the executable permissions of the binary file, with:: 400*4882a593Smuzhiyun 401*4882a593Smuzhiyun chmod 755 HelloWorld.class 402*4882a593Smuzhiyun 403*4882a593SmuzhiyunAnd then execute it:: 404*4882a593Smuzhiyun 405*4882a593Smuzhiyun ./HelloWorld.class 406*4882a593Smuzhiyun 407*4882a593Smuzhiyun 408*4882a593SmuzhiyunTo execute Java Jar files, simple chmod the ``*.jar`` files to include 409*4882a593Smuzhiyunthe execution bit, then just do:: 410*4882a593Smuzhiyun 411*4882a593Smuzhiyun ./Application.jar 412*4882a593Smuzhiyun 413*4882a593Smuzhiyun 414*4882a593SmuzhiyunTo execute Java Applets, simple chmod the ``*.html`` files to include 415*4882a593Smuzhiyunthe execution bit, then just do:: 416*4882a593Smuzhiyun 417*4882a593Smuzhiyun ./Applet.html 418*4882a593Smuzhiyun 419*4882a593Smuzhiyun 420*4882a593Smuzhiyunoriginally by Brian A. Lantz, brian@lantz.com 421*4882a593Smuzhiyunheavily edited for binfmt_misc by Richard Günther 422*4882a593Smuzhiyunnew scripts by Colin J. Watson <cjw44@cam.ac.uk> 423*4882a593Smuzhiyunadded executable Jar file support by Kurt Huwig <kurt@iku-netz.de> 424