'\" t .\" @(#)java.1 1.9 98/06/30 SMI; .\" Copyright (c) 1996 Sun Microsystems, Inc. .\" All Rights Reserved. '\"macro stdmacro .TH java 1 "20 May 1998" .SH NAME java \- Java interpreter .\" .\" This document was created by saving an HTML file as text .\" from the JavaSoft web site: .\" .\" http://www.javasoft.com:80/products/jdk/1.1/docs/tooldocs/solaris/index.html .\" .\" and adding appropriate troff macros. Because the JavaSoft web site .\" man pages can change without notice, it may be helpful to diff .\" files to identify changes other than new functionality. .\" .SH SYNOPSIS .B java [ .BR \-cs " | " \-checksource ] [ .BI \-classpath path ] .if n .ti +5n [ \f3\-DpropertyName\f1=\f2newValue\f1 ] .if t .ti +5n [ .B \-debug ] [ .B \-fullversion ] .if n .ti +5n [ .B \-help ] [ .BI \-ms x ] [ .BI \-mx x ] [ .B \-noasyncgc ] .ti +5n [ .B \-noclassgc ] [ .B \-noverify ] [ .BI \-oss x ] [ .B \-prof ] .if n .ti +5n [ .BI \-prof file ] [ .BI \-ss x ] [ .B \-t ] .if t .ti +5n [ .BR \-v " | " \-verbose ] .if n .ti +5n [ .B \-verbosegc ] [ .B \-verify ] [ .B \-verifyremote ] .if n .ti +5n [ .B \-version ] .if t .ti +5n .I classname .br .B java_g [ .BR \-cs " | " \-checksource ] [ .BI \-classpath path ] .if n .ti +5n [ \f3\-DpropertyName\f1=\f2newValue\f1 ] .if t .ti +5n [ .B \-debug ] [ .B \-fullversion ] .if n .ti +5n [ .B \-help ] [ .BI \-ms x ] [ .BI \-mx x ] [ .B \-noasyncgc ] .ti +5n [ .B \-noclassgc ] [ .B \-noverify ] [ .BI \-oss x ] [ .B \-prof ] .if n .ti +5n [ .BI \-prof file ] [ .BI \-ss x ] [ .B \-t ] .if t .ti +5n [ .BR \-v " | " \-verbose ] .if n .ti +5n [ .B \-verbosegc ] [ .B \-verify ] [ .B \-verifyremote ] .if n .ti +5n [ .B \-version ] .if t .ti +5n .I classname .SH DESCRIPTION .IX "Java interpreter" "" "Java interpreter \(em \fLjava\fP" .IX "java" "" "\fLjava\fP \(em Java interpreter" The .B java command executes Java\(tm bytecodes created by the Java compiler, \f3javac\f1. The JIT (just in time) compiler compiles these bytecodes into machine instructions by default in the Solaris Java VM when using \f3java\f1. (To disable this default, see the .B USAGE section below.) .LP The .I classname argument is the name of the class to be executed and must be fully qualified by including the package in the name, for example: .sp 1n .RS .B example% java java.lang.String .RE .sp 1n Note that any arguments that appear after .I classname on the command line are passed to the .B main(\|) method of the class. .LP The bytecodes for the class are put in a file called .I classname.class by compiling the corresponding source file with .B javac. All Java bytecode files end with the filename extension .B .class which the compiler automatically adds when the class is compiled. The .I classname argument must contain a .B main(\|) method defined as follows: .sp 1n .RS .ft3 .nf class Aclass { public static void main(String argv[]){ . . . } } .fi .ft1 .sp 1n .RE The .B java command executes the .B main(\|) method and exits unless .B main(\|) creates one or more threads. In this case, .B java doesn't exit until the last thread exits. .LP When defining classes, specify their location with the .SB CLASSPATH environment variable, which consists of a colon-separated list of directories that specifies the path. For example: .sp 1n .RS .B .:/home/avh/classes .RE .sp 1n Note that the system always appends the location of the system classes onto the end of the class path unless using the .BR \-classpath option to specify a path. .LP Ordinarily, compile source files with .BR javac , then run the program using .BR java . However, .B java can be used to compile and run programs when the .BR \- 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 .B java command repeats this procedure until all the classes are correctly compiled and loaded. .LP The interpreter determines whether a class is legitimate by verification that ensures that the bytecodes, being interpreted, do not violate language constraints. .LP .B java_g is a non-optimized version of .B java for use with debuggers like .BR jdb (1). When using .B java_g to run a program that loads a shared library, you must supply a debug version of the library. You can create a debug version of a library by simply appending "\f3_g\f1" to the name of the file. For example, if the library was .BR libhello.so , the debug version of the library would be named .BR libhello.so_g . .SH OPTIONS .TP 15 .BR \-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. .TP 15 .BI \-classpath path Specifies the .I path that .B java uses to look up classes. This overrides the default or .SB CLASSPATH environment variable, if it is set. Directories are separated by colons. Thus, the general format for .I path is: .RS 20 .sp 1n .B .: .sp 1n .RE .RS 15 For example: .RE .sp 1n .RS 20 .B .:/home/avh/classes:/usr/local/java/classes .RE .sp 1n .TP 15 \f3\-DpropertyName\f1=\f2newValue\f1 Redefines a property value where .I propertyName is the name of the property value to be changed and .I newValue is the value. For example, this command line .sp 1n .RS 20 .B example% java -Dawt.button.color=green ... .RE .sp 1n .RS 15 sets the value of the property .B awt.button.color to green. .B java accepts any number of .B \-D options on the command line. .RE .TP 15 .B \-debug Allows the Java debugger - .BR jdb (1) - to attach itself to this .B java session. When .B \-debug is specified on the command line .B java displays a password that must be used when starting the debugging session. .TP 15 .B \-fullversion Displays full version information. .TP 15 .B \-help Displays a usage message. .TP 15 .BI \-ms x Sets the startup size of the memory allocation pool (the garbage collected heap) to .I x. The default is 4 megabytes of memory. .I x must be > 1000 bytes and must be less than or equal to the maximum memory size (specified with the .B \-mx option). .sp 1n By default, .I x is measured in bytes. To specify .I x in either kilobytes or megabytes, append "k" for kilobytes or "m" for megabytes. .br .ne 6 .TP 15 .BI \-mx x Sets the maximum size of the memory allocation pool (the garbage collected heap) to .I x. The default is 16 megabytes of memory. .I x must be > 1000 bytes and must be greater than or equal to the startup memory size (specified with the .B \-ms option). .sp 1n By default, .I x is measured in bytes. To specify .I x in either kilobytes or megabytes, append the letter "k" for kilobytes or the letter "m" for megabytes. .br .ne 4 .TP 15 .B \-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. .TP 15 .B \-noclassgc Turns off garbage collection of Java classes. By default, the Java interpreter reclaims space for unused Java classes during garbage collection. .TP 15 .B \-noverify Turns verification off. .TP 15 .BI \-oss x Each Java thread has two stacks: one for Java code and one for C code. The .B \-oss option sets the maximum stack size that can be used by Java code in a thread to .I x. Every thread that is spawned during the execution of the program passed to .B java has .I x as its Java stack size. The default units for .I x are bytes and .I x must be > 1000 bytes. .sp 1n To modify the meaning of .IR x , append either the letter "k" for kilobytes or the letter "m" for megabytes. The default stack size is 400 kilobytes (\f3\-oss400k\f1). .TP 15 .B \-prof Starts Java runtime with .BR java (1) profiling enabled. By default, this puts profile results in the file .BR ./java.prof . This option only works with .BR java_g . .TP 15 .BI \-prof file Starts Java runtime with .BR 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 .B \-prof:myprog.prof enables profiling and puts the profile results in the file .B myprog.prof rather than in the default file .BR ./java.prof . .TP 15 .BI \-ss x Each Java thread has two stacks: one for Java code and one for C code. The .B \-ss option sets the maximum stack size that can be used by C code in a thread to .I x. Every thread that is spawned during the execution of the program passed to .B java has .I x as its C stack size. The default units for .I x are bytes and .I x must be > 1000 bytes. .sp 1n To modify the meaning of .IR x , append either the letter "k" for kilobytes or the letter "m" for megabytes. The default stack size is 128 kilobytes (\f3\-ss128k\f1). .TP 15 .B \-t Prints a trace of the instructions executed (\f3java_g\f1 only). .TP 15 .BR \-v " | " \-verbose Causes .B java to print a message to .B stdout each time a class file is loaded. .TP 15 .B \-verbosegc Causes the garbage collector to print messages whenever it frees memory. .TP 15 .B \-verify Runs the verifier on all code. .br .ne 2 .TP 15 .B \-verifyremote Runs the verifier on all code that is loaded into the system via a classloader. The .B \-verifyremote option is the default for the interpreter. .TP 15 .B \-version Displays the build version information. .SH USAGE The .B java command uses the JIT compiler by default. Either of the following methods may be used to disable this default: (1) set the .SB JAVA_COMPILER environment variable to "NONE", or (2) use the .B \-D option as follows: .sp 1n .RS \f3example% java -Djava.compiler=none \f2classname\f1 .RE .sp 1n .SH ENVIRONMENT VARIABLES .TP 15 .SB CLASSPATH Used to provide the system with a path to user-defined classes. Directories are separated by colons, for example: .RS 20 .sp 1n .B .:/home/avh/classes:/usr/local/java/classes .sp 1n .RE .TP 15 .SB JAVA_COMPILER Overrides the default value for the property .B java.compiler uses to speed program execution. The default value is \*(lqsunwjit\*(rq which causes the file .B libsunwjit.so to be used. A value of \*(lqNONE\*(rq turns off compilation. .br .ne 4 .SH FILES .TP 20 .B libsunwjit.so Library containing runtime bytecode optimization files. .SH ATTRIBUTES See .BR attributes (5) for descriptions of the following attributes: .br .ne 11 .sp 1n .TS box; cbp-1 | cbp-1 l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE = Availability SUNWjvrt .TE .SH SEE ALSO .BR javac (1), .BR javadoc (1), .BR javah (1), .BR javap (1), .BR jdb (1)