java

 




NAME

java - Java interpreter

SYNOPSIS

java [ -cs | -checksource ] [ -classpathpath ] [ -Dproperty=value ] [ -debug ] [ -fullversion ] [ -help ] [ -msx ] [ -mxx ] [ -noasyncgc ] [ -noclassgc ] [ -noverify ] [ -ossx ] [ -prof ] [ -proffile ] [ -ssx ] [ -t ] [ -v | -verbose ] [ -verbosegc ] [ -verify ] [ -verifyremote ] [ -version ] classname args java_g [ -cs | -checksource ] [ -classpathpath ] [ -Dproperty=value ] [ -debug ] [ -fullversion ] [ -help ] [ -msx ] [ -mxx ] [ -noasyncgc ] [ -noclassgc ] [ -noverify ] [ -ossx ] [ -prof ] [ -proffile ] [ -ssx ] [ -t ] [ -v | -verbose ] [ -verbosegc ] [ -verify ] [ -verifyremote ] [ -version ] classname args

DESCRIPTION

The java command executes Java bytecodes created by the Java compiler, javac. The JIT (just in time) compiler compiles these bytecodes into machine instructions by default in the Solaris Java VM when using java. (To disable this default, see the USAGE section below.) The classname argument is the name of the class to be exe- cuted and must be fully qualified by including the package in the name, for example: example% java java.lang.String Note that any arguments that appear after classname on the command line are passed to the main() method of the class. The bytecodes for the class are put in a file called classname.class 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. The classname argument must contain a main() method defined as follows: class Aclass { public static void main(String argv[]){ . . . } } The java command executes the main() method and exits unless main() creates one or more threads. In this case, java doesn't exit until the last thread exits. When defining classes, specify their location with the CLASSPATH environment variable, which consists of a colon- separated list of directories that specifies the path. For example: .:/home/avh/classes Note that the system always appends the location of the sys- tem classes onto the end of the class path. Ordinarily, 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, the modification date is 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. The java command repeats this procedure until all the classes are correctly compiled and loaded. The interpreter determines whether a class is legitimate by verification that ensures that the bytecodes, being inter- preted, do not violate language constraints. java_g is a non-optimized version of java for use with debuggers like jdb(1). When using java_g to run a program that loads a shared library, supply a debug version of the library. You can create a debug version of a library by simply appending "_g" to the name of the file. For exam- ple, if the library was libhello.so, the debug version of the library would be named libhello.so_g.

OPTIONS

-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. -classpathpath Specifies the path that java uses to look up classes. This overrides the default or CLASSPATH environment variable, if it is set. The system appends the location of the system classes onto the end of path. Directories are separated by colons. Thus, the general format for path is: .:<your_path> For example: .:/home/avh/classes:/usr/local/java/classes -Dproperty=value Redefines a property value where property is the name of the property value to be changed and value is the value. For exam- ple, this command line example% java -Dawt.button.color=green ... sets the value of the property awt.button.color to green. java accepts any number of -D options on the command line. -debug Allows the Java debugger - jdb(1) - to attach itself to this java session. When -debug is specified on the command line java displays a password that must be used when starting the debugging session. -fullversion Displays full version information. -help Displays a usage message. -msx Sets the startup size of the memory alloca- tion pool (the garbage collected heap) to x. The default is 4 megabytes of memory. x must be > 1000 bytes and must be less than or equal to the maximum memory size (specified with the -mx option). By default, x is measured in bytes. To specify x in either kilobytes or megabytes, append "k" for kilobytes or "m" for mega- bytes. -mxx Sets the maximum size of the memory alloca- tion pool (the garbage collected heap) to x. The default is 16 megabytes of memory. x must be > 1000 bytes and must be greater than or equal to the startup memory size (speci- fied with the -ms option). By default, x is measured in bytes. To specify x in either kilobytes or megabytes, append 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. -noclassgc Turns off garbage collection of Java classes. By default, the Java interpreter reclaims space for unused Java classes during garbage collection. -noverify Turns verification off. -ossx 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 pro- gram passed to java has x as its Java stack size. The default units for x are bytes and x must be > 1000 bytes. To modify the meaning of x, append either the letter "k" for kilobytes or the letter "m" for megabytes. The default stack size is 400 kilobytes (-oss400k). -prof Starts Java runtime with java(1) profiling enabled. By default, this puts profile results in the file ./java.prof. This option only works with java_g. -proffile Starts Java runtime with java(1) profiling enabled. This form of the option allows the user to specify a different output file for the profile information. For example, the option -prof:myprog.prof enables profiling and puts the profile results in the file myprog.prof rather than in the default file ./java.prof. -ssx 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 and x must be > 1000 bytes. To modify the meaning of x, append either the letter "k" for kilobytes or the letter "m" for megabytes. The default stack size is 128 kilobytes (-ss128k). -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. -verbosegc Causes the garbage collector to print mes- sages whenever it frees memory. -verify Runs the verifier on all code. -verifyremote Runs the verifier on all code that is loaded into the system via a classloader. The -ver- ifyremote option is the default for the interpreter. -version Displays the build version information. USAGE The java command uses the JIT compiler by default. Either of the following methods may be used to disable this default: (1) set the JAVA_COMPILER environment variable to "NONE", or (2) use the -D option as follows: example% java -Djava.compiler=none classname ENVIRONMENT VARIABLES CLASSPATH Used to provide the system with a path to user-defined classes. Directories are separated by colons, for example: .:/home/avh/classes:/usr/local/java/classes JAVA_COMPILER Overrides the default value for the property java.compiler uses to speed program execu- tion. The default value is "sunwjit" which causes the file libsunwjit.so to be used. A value of "NONE" turns off compilation.

FILES

libsunwjit.so Library containing runtime bytecode optimization files.

ATTRIBUTES

See attributes(5) for descriptions of the following attri- butes: __________________________________ | ATTRIBUTE TYPE| ATTRIBUTE VALUE| |_______________|_________________| | Availability | SUNWjvrt | |_______________|_________________|

SEE ALSO

javac(1), javadoc(1), javah(1), javap(1), jdb(1) SunOS 5.8 Last change: 18 Dec 1998 6