Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Documentation/java.txt: convert to ReST markup

- Fix document title;
- use quote blocks where needed;
- use monotonic fonts for config options and file names;
- adjust whitespaces and blank lines;
- add it to the user's book.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

+123 -109
+123 -109
Documentation/java.txt
··· 1 - Java(tm) Binary Kernel Support for Linux v1.03 2 - ---------------------------------------------- 1 + Java(tm) Binary Kernel Support for Linux v1.03 2 + ---------------------------------------------- 3 3 4 4 Linux beats them ALL! While all other OS's are TALKING about direct 5 5 support of Java Binaries in the OS, Linux is doing it! ··· 19 19 as the application itself). 20 20 21 21 2) You have to compile BINFMT_MISC either as a module or into 22 - the kernel (CONFIG_BINFMT_MISC) and set it up properly. 22 + the kernel (``CONFIG_BINFMT_MISC``) and set it up properly. 23 23 If you choose to compile it as a module, you will have 24 24 to insert it manually with modprobe/insmod, as kmod 25 - cannot easily be supported with binfmt_misc. 25 + cannot easily be supported with binfmt_misc. 26 26 Read the file 'binfmt_misc.txt' in this directory to know 27 27 more about the configuration process. 28 28 29 29 3) Add the following configuration items to binfmt_misc 30 - (you should really have read binfmt_misc.txt now): 31 - support for Java applications: 30 + (you should really have read ``binfmt_misc.txt`` now): 31 + support for Java applications:: 32 + 32 33 ':Java:M::\xca\xfe\xba\xbe::/usr/local/bin/javawrapper:' 33 - support for executable Jar files: 34 + 35 + support for executable Jar files:: 36 + 34 37 ':ExecutableJAR:E::jar::/usr/local/bin/jarwrapper:' 35 - support for Java Applets: 38 + 39 + support for Java Applets:: 40 + 36 41 ':Applet:E::html::/usr/bin/appletviewer:' 37 - or the following, if you want to be more selective: 42 + 43 + or the following, if you want to be more selective:: 44 + 38 45 ':Applet:M::<!--applet::/usr/bin/appletviewer:' 39 46 40 47 Of course you have to fix the path names. The path/file names given in this 41 - document match the Debian 2.1 system. (i.e. jdk installed in /usr, 42 - custom wrappers from this document in /usr/local) 48 + document match the Debian 2.1 system. (i.e. jdk installed in ``/usr``, 49 + custom wrappers from this document in ``/usr/local``) 43 50 44 51 Note, that for the more selective applet support you have to modify 45 - existing html-files to contain <!--applet--> in the first line 46 - ('<' has to be the first character!) to let this work! 52 + existing html-files to contain ``<!--applet-->`` in the first line 53 + (``<`` has to be the first character!) to let this work! 47 54 48 55 For the compiled Java programs you need a wrapper script like the 49 56 following (this is because Java is broken in case of the filename 50 57 handling), again fix the path names, both in the script and in the 51 58 above given configuration string. 52 59 53 - You, too, need the little program after the script. Compile like 54 - gcc -O2 -o javaclassname javaclassname.c 55 - and stick it to /usr/local/bin. 60 + You, too, need the little program after the script. Compile like:: 61 + 62 + gcc -O2 -o javaclassname javaclassname.c 63 + 64 + and stick it to ``/usr/local/bin``. 56 65 57 66 Both the javawrapper shellscript and the javaclassname program 58 67 were supplied by Colin J. Watson <cjw44@cam.ac.uk>. 59 68 60 - ====================== Cut here =================== 61 - #!/bin/bash 62 - # /usr/local/bin/javawrapper - the wrapper for binfmt_misc/java 69 + Javawrapper shell script:: 63 70 64 - if [ -z "$1" ]; then 71 + #!/bin/bash 72 + # /usr/local/bin/javawrapper - the wrapper for binfmt_misc/java 73 + 74 + if [ -z "$1" ]; then 65 75 exec 1>&2 66 76 echo Usage: $0 class-file 67 77 exit 1 68 - fi 78 + fi 69 79 70 - CLASS=$1 71 - FQCLASS=`/usr/local/bin/javaclassname $1` 72 - FQCLASSN=`echo $FQCLASS | sed -e 's/^.*\.\([^.]*\)$/\1/'` 73 - FQCLASSP=`echo $FQCLASS | sed -e 's-\.-/-g' -e 's-^[^/]*$--' -e 's-/[^/]*$--'` 80 + CLASS=$1 81 + FQCLASS=`/usr/local/bin/javaclassname $1` 82 + FQCLASSN=`echo $FQCLASS | sed -e 's/^.*\.\([^.]*\)$/\1/'` 83 + FQCLASSP=`echo $FQCLASS | sed -e 's-\.-/-g' -e 's-^[^/]*$--' -e 's-/[^/]*$--'` 74 84 75 - # for example: 76 - # CLASS=Test.class 77 - # FQCLASS=foo.bar.Test 78 - # FQCLASSN=Test 79 - # FQCLASSP=foo/bar 85 + # for example: 86 + # CLASS=Test.class 87 + # FQCLASS=foo.bar.Test 88 + # FQCLASSN=Test 89 + # FQCLASSP=foo/bar 80 90 81 - unset CLASSBASE 91 + unset CLASSBASE 82 92 83 - declare -i LINKLEVEL=0 93 + declare -i LINKLEVEL=0 84 94 85 - while :; do 95 + while :; do 86 96 if [ "`basename $CLASS .class`" == "$FQCLASSN" ]; then 87 97 # See if this directory works straight off 88 98 cd -L `dirname $CLASS` ··· 129 119 exit 1 130 120 fi 131 121 CLASS=`ls --color=no -l $CLASS | sed -e 's/^.* \([^ ]*\)$/\1/'` 132 - done 122 + done 133 123 134 - if [ -z "$CLASSBASE" ]; then 124 + if [ -z "$CLASSBASE" ]; then 135 125 if [ -z "$FQCLASSP" ]; then 136 126 GOODNAME=$FQCLASSN.class 137 127 else ··· 141 131 echo $0: 142 132 echo " $FQCLASS should be in a file called $GOODNAME" 143 133 exit 1 144 - fi 134 + fi 145 135 146 - if ! echo $CLASSPATH | grep -q "^\(.*:\)*$CLASSBASE\(:.*\)*"; then 136 + if ! echo $CLASSPATH | grep -q "^\(.*:\)*$CLASSBASE\(:.*\)*"; then 147 137 # class is not in CLASSPATH, so prepend dir of class to CLASSPATH 148 138 if [ -z "${CLASSPATH}" ] ; then 149 139 export CLASSPATH=$CLASSBASE 150 140 else 151 141 export CLASSPATH=$CLASSBASE:$CLASSPATH 152 142 fi 153 - fi 143 + fi 154 144 155 - shift 156 - /usr/bin/java $FQCLASS "$@" 157 - ====================== Cut here =================== 145 + shift 146 + /usr/bin/java $FQCLASS "$@" 158 147 148 + javaclassname.c:: 159 149 160 - ====================== Cut here =================== 161 - /* javaclassname.c 150 + /* javaclassname.c 162 151 * 163 152 * Extracts the class name from a Java class file; intended for use in a Java 164 153 * wrapper of the type supported by the binfmt_misc option in the Linux kernel. ··· 179 170 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 180 171 */ 181 172 182 - #include <stdlib.h> 183 - #include <stdio.h> 184 - #include <stdarg.h> 185 - #include <sys/types.h> 173 + #include <stdlib.h> 174 + #include <stdio.h> 175 + #include <stdarg.h> 176 + #include <sys/types.h> 186 177 187 - /* From Sun's Java VM Specification, as tag entries in the constant pool. */ 178 + /* From Sun's Java VM Specification, as tag entries in the constant pool. */ 188 179 189 - #define CP_UTF8 1 190 - #define CP_INTEGER 3 191 - #define CP_FLOAT 4 192 - #define CP_LONG 5 193 - #define CP_DOUBLE 6 194 - #define CP_CLASS 7 195 - #define CP_STRING 8 196 - #define CP_FIELDREF 9 197 - #define CP_METHODREF 10 198 - #define CP_INTERFACEMETHODREF 11 199 - #define CP_NAMEANDTYPE 12 200 - #define CP_METHODHANDLE 15 201 - #define CP_METHODTYPE 16 202 - #define CP_INVOKEDYNAMIC 18 180 + #define CP_UTF8 1 181 + #define CP_INTEGER 3 182 + #define CP_FLOAT 4 183 + #define CP_LONG 5 184 + #define CP_DOUBLE 6 185 + #define CP_CLASS 7 186 + #define CP_STRING 8 187 + #define CP_FIELDREF 9 188 + #define CP_METHODREF 10 189 + #define CP_INTERFACEMETHODREF 11 190 + #define CP_NAMEANDTYPE 12 191 + #define CP_METHODHANDLE 15 192 + #define CP_METHODTYPE 16 193 + #define CP_INVOKEDYNAMIC 18 203 194 204 - /* Define some commonly used error messages */ 195 + /* Define some commonly used error messages */ 205 196 206 - #define seek_error() error("%s: Cannot seek\n", program) 207 - #define corrupt_error() error("%s: Class file corrupt\n", program) 208 - #define eof_error() error("%s: Unexpected end of file\n", program) 209 - #define utf8_error() error("%s: Only ASCII 1-255 supported\n", program); 197 + #define seek_error() error("%s: Cannot seek\n", program) 198 + #define corrupt_error() error("%s: Class file corrupt\n", program) 199 + #define eof_error() error("%s: Unexpected end of file\n", program) 200 + #define utf8_error() error("%s: Only ASCII 1-255 supported\n", program); 210 201 211 - char *program; 202 + char *program; 212 203 213 - long *pool; 204 + long *pool; 214 205 215 - u_int8_t read_8(FILE *classfile); 216 - u_int16_t read_16(FILE *classfile); 217 - void skip_constant(FILE *classfile, u_int16_t *cur); 218 - void error(const char *format, ...); 219 - int main(int argc, char **argv); 206 + u_int8_t read_8(FILE *classfile); 207 + u_int16_t read_16(FILE *classfile); 208 + void skip_constant(FILE *classfile, u_int16_t *cur); 209 + void error(const char *format, ...); 210 + int main(int argc, char **argv); 220 211 221 - /* Reads in an unsigned 8-bit integer. */ 222 - u_int8_t read_8(FILE *classfile) 223 - { 212 + /* Reads in an unsigned 8-bit integer. */ 213 + u_int8_t read_8(FILE *classfile) 214 + { 224 215 int b = fgetc(classfile); 225 216 if(b == EOF) 226 217 eof_error(); 227 218 return (u_int8_t)b; 228 - } 219 + } 229 220 230 - /* Reads in an unsigned 16-bit integer. */ 231 - u_int16_t read_16(FILE *classfile) 232 - { 221 + /* Reads in an unsigned 16-bit integer. */ 222 + u_int16_t read_16(FILE *classfile) 223 + { 233 224 int b1, b2; 234 225 b1 = fgetc(classfile); 235 226 if(b1 == EOF) ··· 238 229 if(b2 == EOF) 239 230 eof_error(); 240 231 return (u_int16_t)((b1 << 8) | b2); 241 - } 232 + } 242 233 243 - /* Reads in a value from the constant pool. */ 244 - void skip_constant(FILE *classfile, u_int16_t *cur) 245 - { 234 + /* Reads in a value from the constant pool. */ 235 + void skip_constant(FILE *classfile, u_int16_t *cur) 236 + { 246 237 u_int16_t len; 247 238 int seekerr = 1; 248 239 pool[*cur] = ftell(classfile); ··· 279 270 } 280 271 if(seekerr) 281 272 seek_error(); 282 - } 273 + } 283 274 284 - void error(const char *format, ...) 285 - { 275 + void error(const char *format, ...) 276 + { 286 277 va_list ap; 287 278 va_start(ap, format); 288 279 vfprintf(stderr, format, ap); 289 280 va_end(ap); 290 281 exit(1); 291 - } 282 + } 292 283 293 - int main(int argc, char **argv) 294 - { 284 + int main(int argc, char **argv) 285 + { 295 286 FILE *classfile; 296 287 u_int16_t cp_count, i, this_class, classinfo_ptr; 297 288 u_int8_t length; ··· 358 349 free(pool); 359 350 fclose(classfile); 360 351 return 0; 361 - } 362 - ====================== Cut here =================== 352 + } 353 + 354 + jarwrapper:: 355 + 356 + #!/bin/bash 357 + # /usr/local/java/bin/jarwrapper - the wrapper for binfmt_misc/jar 358 + 359 + java -jar $1 363 360 364 361 365 - ====================== Cut here =================== 366 - #!/bin/bash 367 - # /usr/local/java/bin/jarwrapper - the wrapper for binfmt_misc/jar 362 + Now simply ``chmod +x`` the ``.class``, ``.jar`` and/or ``.html`` files you 363 + want to execute. 368 364 369 - java -jar $1 370 - ====================== Cut here =================== 371 - 372 - 373 - Now simply chmod +x the .class, .jar and/or .html files you want to execute. 374 365 To add a Java program to your path best put a symbolic link to the main 375 366 .class file into /usr/bin (or another place you like) omitting the .class 376 367 extension. The directory containing the original .class file will be ··· 378 369 379 370 380 371 To test your new setup, enter in the following simple Java app, and name 381 - it "HelloWorld.java": 372 + it "HelloWorld.java":: 382 373 383 374 class HelloWorld { 384 375 public static void main(String args[]) { ··· 386 377 } 387 378 } 388 379 389 - Now compile the application with: 380 + Now compile the application with:: 381 + 390 382 javac HelloWorld.java 391 383 392 - Set the executable permissions of the binary file, with: 384 + Set the executable permissions of the binary file, with:: 385 + 393 386 chmod 755 HelloWorld.class 394 387 395 - And then execute it: 388 + And then execute it:: 389 + 396 390 ./HelloWorld.class 397 391 398 392 399 - To execute Java Jar files, simple chmod the *.jar files to include 400 - the execution bit, then just do 393 + To execute Java Jar files, simple chmod the ``*.jar`` files to include 394 + the execution bit, then just do:: 395 + 401 396 ./Application.jar 402 397 403 398 404 - To execute Java Applets, simple chmod the *.html files to include 405 - the execution bit, then just do 399 + To execute Java Applets, simple chmod the ``*.html`` files to include 400 + the execution bit, then just do:: 401 + 406 402 ./Applet.html 407 403 408 404