java interprets (executes) Java bytecodes.
java [ options ] classname <args> java_g [ options ] classname <args>
The java command executes Java bytecodes created by the Java compiler - javac.The classname argument is the name of the class to be executed. classname must be fully qualified by including its package in the name, for example:
Note that any arguments that appear after classname on the command line are passed to the class'sjava java.lang.Stringmain()
method.java expects the bytecodes for the class to be in a file called classname.class which is generated by compiling the corresponding source file with javac. All Java bytecode files end with the filename extension .class which the compiler automatically adds when the class is compiled. classname must contain a
main()
method defined as follows:java executes theclass Aclass { public static void main(String argv[]){ . . . } }main()
method and then exits unlessmain()
creates one or more threads. If any threads are created bymain()
then java doesn't exit until the last thread exits.When you define your own classes you need to specify their location. Use CLASSPATH to do this. CLASSPATH consists of a colon separated list of directories that specifies the path. For example:
Note that the system always appends the location of the system classes onto the end of the class path unless you use the -classpath option to specify a path..:/home/avh/classesOrdinarily, you compile source files with javac then run the program using java. However, java can be used to compile and run programs when the -cs option is used. As each class is loaded its modification date is compared to the modification date of the class source file. If the source has been modified more recently, it is recompiled and the new bytecode file is loaded. java repeats this procedure until all the classes are correctly compiled and loaded.
The interpreter can determine whether a class is legitimate through the mechanism of verification. Verification ensures that the bytecodes being interpreted do not violate any language constraints.
java_g is a non-optimized version of java suitable for use with debuggers like jdb.
OPTIONS
- -debug
- Allows the Java debugger - jdb to attach itself to this java session. When -debug is specified on the command line java displays a password which must be used when starting the debugging session.
- -cs, -checksource
- When a compiled class is loaded, this option causes the modification time of the class bytecode file to be compared to that of the class source file. If the source has been modified more recently, it is recompiled and the new bytecode file is loaded.
- -classpath path
- Specifies the path java uses to look up classes. Overrides the default or the CLASSPATH environment variable if it is set. Directories are separated by colons. Thus the general format for path is:
For example:.:<your_path>.:/home/avh/classes:/usr/local/java/classes
- -mx x
- Sets the maximum size of the memory allocation pool (the garbage collected heap) to x. The default is 16 megabytes of memory. x must be > 1000 bytes.
By default, x is measured in bytes. You can specify x in either kilobytes or megabytes by appending the letter "k" for kilobytes or the letter "m" for megabytes.
- -ms x
- Sets the startup size of the memory allocation pool (the garbage collected heap) to x. The default is 1 megabyte of memory. x must be > 1000 bytes.
By default, x is measured in bytes. You can specify x in either kilobytes or megabytes by appending the letter "k" for kilobytes or the letter "m" for megabytes.
- -noasyncgc
- Turns off asynchronous garbage collection. When activated no garbage collection takes place unless it is explicitly called or the program runs out of memory. Normally garbage collection runs as an asynchronous thread in parallel with other threads.
- -ss x
- Each Java thread has two stacks: one for Java code and one for C code. The -ss option sets the maximum stack size that can be used by C code in a thread to x. Every thread that is spawned during the execution of the program passed to java has x as its C stack size. The default units for x are bytes. x must be > 1000 bytes.
You can modify the meaning of x by appending either the letter "k" for kilobytes or the letter "m" for megabytes. The default stack size is 128 kilobytes ("-ss 128k").
- -oss x
- Each Java thread has two stacks: one for Java code and one for C code. The -oss option sets the maximum stack size that can be used by Java code in a thread to x. Every thread that is spawned during the execution of the program passed to java has x as its Java stack size. The default units for x are bytes. x must be > 1000 bytes.
You can modify the meaning of x by appending either the letter "k" for kilobytes or the letter "m" for megabytes. The default stack size is 400 kilobytes ("-oss 400k").
- -t
- Prints a trace of the instructions executed (java_g only).
- -v, -verbose
- Causes java to print a message to stdout each time a class file is loaded.
- -verify
- Runs the verifier on all code.
- -verifyremote
- Runs the verifier on all code that is loaded into the system via a classloader. verifyremote is the default for the interpreter.
- -noverify
- Turns verification off.
- -verbosegc
- Causes the garbage collector to print out messages whenever it frees memory.
- -DpropertyName=newValue
- Redefines a property value. propertyName is the name of the property whose value you want to change and newValue is the value to change it to. For example, this command line
sets the value of the property awt.button.color to green. java accepts any number of -D options on the command line.java -Dawt.button.color=green ...
- CLASSPATH
- Used to provide the system a path to user-defined classes. Directories are separated by colons, for example,
.:/home/avh/classes:/usr/local/java/classes
javac, jdb, javah, javap, javadoc