'\" t .\" @(#)java.1 1.14 99/02/22 SMI; .\" Copyright 1999 Sun Microsystems, Inc. All rights reserved. .\" Copyright 1999 Sun Microsystems, Inc. Tous droits réservés. .\" '\"macro stdmacro .TH java 1 "22 Feb 1999" .SH NAME java \- Java interpreter .SH SYNOPSIS .LP .B java [ .I threads-flag ] [ .IB options ] .I class [ .I argument ... ] .LP .B java [ .I threads-flag ] [ .I options ] .BI -jar " file.jar" .if n .ti +5n [ .I argument ... ] .LP .B oldjava [ .I threads-flag ] [ .I options ] .I class [ .I argument ... ] .SH PARAMETERS Options may be in any order. For a discussion of parameters which apply to a specific option, see .B OPTIONS below. .TP 15 .I threads-flag .B green or .BI native . See Solaris Multithreading Options. .TP 15 .I options Command-line options. See .B OPTIONS below. .TP .I class Name of the class to be invoked. .TP .I file.jar Name of the jar file to be invoked. Used only with the .B \-jar option. .SH DESCRIPTION .IX "Java interpreter" "" "Java interpreter \(em \fLjava\fP" .IX "java" "" "\fLjava\fP \(em Java interpreter" .LP The .B java tool launches a Java application. It does this by starting a Java runtime environment, loading a specified class, and invoking that class's .B main method. The method must have the following signature: .LP .ft 3 .nf public static void main(String args[]) .fi .ft 1 .LP The method must be declared .B public and .BR static , it must not return any value, and it must accept a .B String array as a parameter. By default, the first non-option argument is the name of the class to be invoked. A fully-qualified class name should be used. If the .B \-jar option is specified, the first non-option argument is the name of a JAR archive containing class and resource files for the application, with the startup class indicated by the Main-Class manifest header. .LP The Java runtime searches for the startup class, and other classes used, in three sets of locations: the bootstrap class path, the installed extensions, and the user class path. .LP Non-option arguments after the class name or JAR file name are passed to the main function. .LP .SS Java and Oldjava .IX "java" "Java and Oldjava" "\fLjava\fP \(em Java interpreter" .LP On Solaris systems, the java launcher tool comes in two variations: java, which implements all 1.2 features; and .BR oldjava , a limited-feature launcher tool, which supports programming techniques that are incompatible with some 1.2 features. These are the differences between .B java and .BR oldjava : .TP 2 \(bu The .B oldjava launcher does not support the extension mechanism, though it can, of course, use extension packages as class and resource archives. .TP 2 \(bu The .B oldjava launcher uses the bootstrap class loader for all classes, while the .B java launcher uses the bootstrap class loader only for bootstrap classes. .TP 2 \(bu With .BR java , the .B \-classpath and .B \-cp options specify a search path for user classes, and cannot be used to specify locations for bootstrap classes. With .B oldjava the .B \-classpath and .B \-cp options specify locations for all classes, including bootstrap classes. .RS 2 .LP Note that .B java and .B oldjava do not differ in their use of the .SB CLASSPATH environment variable. Unless overridden by .B \-classpath or .BR \-cp , .SB CLASSPATH always specifies the location of user classes, but says nothing about the bootstrap classes. .RE .TP 2 \(bu The .B oldjava launcher supports all the 1.2 security features. With .BR oldjava , however, classes loaded from the class path will not have a protection domain and will therefore have all permissions which is true only for bootstrap classes with the .B java launcher. .LP This command using .B oldjava .LP \f3example% oldjava -classpath \fP\f2path\fP ... .fi .ft 1 .LP is equivalent to this command using .B java .LP .nf \f3example% java -Xbootclasspath:\fP\f2path\fP\f3 -Djava.ext.dirs= ...\fP .fi .ft 1 .LP where in both cases < .I path > contains the file .BR rt.jar . (See the JDK File Structure document for a description of .B rt.jar and its location in the JDK software.) .LP .SS The JIT .IX "java" "The JIT" "\fLjava\fP \(em Java interpreter" .LP The default behavior of the launcher is to execute bytecodes using a Just In Time compiler, or JIT. The default compiler is located at .BR jre/lib/sparc/libsunwjit.so . When a class is loaded, the JIT translates the class bytecodes into native machine code. Using a JIT causes a slight delay after each class load, but can improve overall program performance. In some cases, execution time will improve by a factor of ten. .LP If the JIT is disabled, bytecodes are executed directly by an interpreter. There are two ways to disable the JIT: .TP 2 \(bu Set the environment variable .SB JAVA_COMPILER to .BR NONE , the .BR setenv (1) command. .LP .RS 2 .ft 3 .nf example% setenv JAVA_COMPILER NONE .fi .ft 1 .RE .TP 2 \(bu Use the .B \-D command-line option to set .BR java.compiler " to " NONE . .LP .RS 2 .ft 3 .nf example% java -Djava.compiler=NONE myapp .fi .ft 1 .RE .LP Using the command-line option overrides the setting of the .SB JAVA_COMPILER environment variable. .LP You can also use .SB JAVA_COMPILER or .B java.compiler to the specify that an alternative JIT should be used: .LP .ft 3 .nf example% setenv JAVA_COMPILER foo .fi .ft 1 .LP or .LP .ft 3 .nf example% java -Djava.compiler=foo myapp .fi .ft 1 .LP The letters .B lib are prepended to .B foo and an .B .so filename extension is added, so that, in this example, the virtual machine will search for a JIT compiler named .BR libfoo.so . The search for the alternative compiler is made in the .B jre/lib/sparc directory and on the path specified by the .SB LD_LIBRARY_PATH environment variable. If no such compiler is found, the virtual machine will default to using the interpreter. .SH OPTIONS .LP The launcher has a set of standard options that are supported on the current runtime environment and will be supported in future releases. An additional set of non-standard options are specific to the current virtual machine implementation and are subject to change in the future. Non-standard options begin with .BR \-X . .SS Standard Options .IX "java" "Standard Options" "\fLjava\fP \(em Java interpreter" .BI \-classpath " classpath" .br .BI \-cp " classpath" .RS 15 Specify a list of directories, JAR archives, and ZIP archives to search for class files. Class path entries are separated by colons (:). Specifying .B \-classpath or .B \-cp overrides any setting of the .SB CLASSPATH environment variable. .LP Used with .BR java , the .B \-classpath or .B \-cp options only specify the class path for user classes. Used with .BR oldjava , .B \-classpath or .B \-cp specify the class path for both user classes and bootstrap classes. .LP If .B \-classpath and .B \-cp are not used and .SB CLASSPATH is not set, the user class path consists of the current directory (.). .LP For more information on class paths, see Setting the Class Path. .RE .TP 15 .B \-debug This has been replaced by .BR \-Xdebug . .TP 15 .BI \-D property=value Set a system property value. .TP .B \-jar Execute a program encapsulated in a JAR archive. The first argument is the name of a JAR file instead of a startup class name. In order for this option to work, the manifest of the JAR file must contain a line of the form \f3Main-Class:\f1\f2classname\f1. Here, .I classname identifies the class having the .B public static void main(String[] args) method that serves as your application's starting point. See the Jar tool reference page and the Jar trail of the Java Tutorial for information about working with Jar files and Jar-file manifests. When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored. .RS .LP The .B oldjava tool does not support the .B \-jar option. .RE .TP .B \-noclassgc This has been replaced by .BR \-Xnoclassgc . .TP 15 .BI \-oss n This has been replaced by .BI -X0ss n . .TP 15 .BI \-ms h This has been replaced by .BI \-Xms n . .TP 15 .BI \-mx n This has been replaced by .BI \-Xmx n . .TP 15 .BI \-ss n This has been replaced by .BI \-Xss n . .TP 15 .B \-t This has been replaced by .BR \-Xt . .TP 15 .B \-tm This has been replaced by .BR \-Xtm . .LP .B \-verbose .br .BI \-verbose: class .RS 15 Display information about each class loaded. .RE .TP 15 .B \-verbosegc This has been replaced by .BR \-verbose:gc . .TP 15 .B \-verbose:gc Report on each garbage collection event. .TP 15 .B \-verbose:jni Report information about use of native methods and other Java Native Interface activity. .TP 15 .B \-version Display version information and exit. .LP .B \-? .br .B \-help .RS 15 Display usage information and exit. .RE .TP 15 .B \-X Display information about non-standard options and exit. .LP .SS Non-Standard Options .IX "java" "Non-Standard Options" "\fLjava\fP \(em Java interpreter" .TP 15 .BI \-Xbootclasspath: bootclasspath Specify a colon-separated list of directories, JAR archives, and ZIP archives to search for boot class files. These are used in place of the boot class files included in the JDK 1.2 software. .TP 15 .B \-Xdebug Start with the debugger enabled. The Java interpereter prints out a password for the use of .BR jdb (1). Refer to .BR jdb (1) description for more details and an example. .TP 15 .B \-Xcheck:jni Perform additional check for Java Native Interface functions. .TP 15 .B \-Xnoclassgc Disable class garbage collection .TP 15 .BI -Xms n Specify the initial size of the memory allocation pool. This value must greather than 1000. To multiply the value by 1000, append the letter .BR k . To multiply the value by 1 million, append the letter .BR m . The default value is 1m. .TP 15 .BI \-Xmx n Specify the maximum size of the memory allocation pool. This value must greather than 1000. To multiply the value by 1000, append the letter .BR k . To multiply the value by 1 million, append the letter .BR m . The default value is 16m. .TP 15 .BI \-Xoss n Each Java thread has two stacks: one for Java code and one for C code. The .B \-Xoss option sets the maximum stack size that can be used by Java code in a thread to .I n. Every thread that is spawned during the execution of the program passed to .B java has .I n as its Java stack size. The default units for .I n are bytes and .I n must be > 1000 bytes. .sp 1n To modify the meaning of .IR n , append either the letter .B k for kilobytes or the letter .B m for megabytes. The default stack size is 400 kilobytes (\f3\-Xoss400k\f1). .TP 15 \f3\-Xrunhprof[:help][:\f2suboption\f3=\f2value\f1,...] Enables cpu, heap, or monitor profiling. This option is typically followed by a list of comma-separated .IR suboption = value pairs. Run the command .B java -Xrunhprof:help to obtain a list of suboptions and their default values. .\" .TP 15 .\" -Xcheck:jni .\" Perform additional check for Java Native Interface functions. .\" .TP 15 .\" -Xverify .\" -Xverify:all .\" Verify that all class files obey language constraints. .\" .TP 15 .\" -Xverify:remote .\" Verify only remote class files. This is the default .\" verification level. .\" .TP 15 .\" -Xverify:none .\" Disable class file verification. .TP 15 .BI \-Xprof[: file ] Enable profiling. If no file is specified, write results to .B java.prof in the current directory. .TP 15 .BI \-Xss n Each Java thread has two stacks: one for Java code and one for C code. The .B \-Xss option sets the maximum stack size that can be used by C code in a thread to .I n. Every thread that is spawned during the execution of the program passed to .B java has .I n as its C stack size. The default units for .I n are bytes and .I n must be > 1000 bytes. .sp 1n To modify the meaning of .IR n , append either the letter .B k for kilobytes or the letter .B m for megabytes. The default stack size is 128 kilobytes (\f3\-Xss128k\f1). .TP 15 .B \-Xrs Reduce the use of operating system signals. .TP 15 .B \-Xsqnopause Do not pause for user interaction on .BR siqquit . .TP 15 .B \-Xt Turns on instruction tracing. .TP 15 .B \-Xtm Turns on method tracing. .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 .RE .br .ne 12 .SH ATTRIBUTES See .BR attributes (5) for a description of the following attributes: .SS java .IX "java" "java" "\fLjava\fP \(em Java interpreter" .sp .TS box; cbp-1 | cbp-1 l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE = Availability SUNWjvrt, SUNWjvdev .TE .SS oldjava .IX "java" "oldjava" "\fLjava\fP \(em Java interpreter" .sp .TS box; cbp-1 | cbp-1 l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE = Availability SUNWjvdev .TE .SH SEE ALSO .BR javac (1), .BR jdb (1), .BR javac (1), .BR jar (1), .BR set (1) .LP See (or search java.sun.com) for the following: .TP 10 Solaris Multithreading Options @ http://java.sun.com/products/jdk/1.2/docs/tooldocs/solaris/threads.html .TP 10 JDK File Structure @ http://java.sun.com/products/jdk/1.2/docs/tooldocs/solaris/jdkfiles.html .TP 10 Setting the Classpath @ http://java.sun.com/products/jdk/1.2/docs/tooldocs/solaris/classpath.html .TP 10 JAR Files @ http://java.sun.com/docs/books/tutorial/jar/