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