jre interprets (executes) Java bytecodes.
jre [ options ] classname <args>
The jre command executes Javaclass
files. Theclassname
argument is the name of the class to be executed. Any arguments to be passed to the class must be placed after theclassname
on the command line.Class paths for the Solaris version of the jre tool can be specified using the CLASSPATH environment variable or by using the -classpath or -cp options. The Windows version of the jre tool ignores the CLASSPATH environment variable. For both Solaris and Windows, the -cp option is recommend for specifying class paths when using jre.
Using a JIT
This release supports execution with a Just In Time bytecode compiler, or JIT. 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.This release does not use a JIT by default. To use a JIT, pass the name of the JIT via the JAVA_COMPILER environment variable or the java.compiler property. If JAVA_COMPILER and java.compiler have conflicting values, java.compiler is used.
The Solaris version of the JDK software includes a JIT named "sunwjit". You can enable this JIT via the JAVA_COMPILER environment variable:
% setenv JAVA_COMPILER sunwjit % jre MyClassTo disable the JIT, unset JAVA_COMPILER:% unsetenv JAVA_COMPILERTo enable the JIT from the command line, use the -D option:% jre -Djava.compiler=sunwjit MyClass
JAR Files and Extensions
In this release, the -new option must be used when launching a program that is contained in a JAR file or when launching a program that makes use of extensions. The need to use the -new option will be removed in a future release.
JAR files
A program can be encapsulated in a JAR archive. The archive can contain all the class files and resources that define the program. In this release, program files in a JAR archive can be passed to the launcher as a unit, using the -new and -jar options in conjunction:% jre -new -jar foo.jarExtensions
In this release, programs that make use of extensions must be launched by using the -new option:% jre -new MyClass
The Java Runtime Interpreter has a set of standard options that are supported on the current Java virtual machine (VM) and will be supported on futures VMs. In addition, there is a set of non-standard options that are supported on the current VM, but are subject to change in future VMs. The non-standard options begin with -X.
Standard Options
- -classpath path(s); -cp path(s)
- Specifies the path or paths that jre uses to look up classes. Overrides the default or the CLASSPATH environment variable if it is set. If more than one path is specified, they must be separated by colons. Each path should end with the directory containing the class file(s) to be executed. However, if a file to be executed is a
zip
orjar
file, the path to that file must end with the file's name. Here is an example of an argument for -classpath that specifies three paths consisting of the current directory and two additional paths:.:/home/xyz/classes:/usr/local/java/classes/MyClasses.jar
- -help
- Print a usage message.
- -v, -verbose, -verbose:class
- Causes java to print a message to stdout each time a class file is loaded.
- -verbose:gc
- Causes the garbage collector to print out messages whenever it frees memory.
- -verbose:jni
- Prints JNI-related messages including information about which native methods have been linked and warnings about excessive creation of local references.
- -DpropertyName=newValue
- Defines 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
% jre -Dawt.button.color=green ...sets the value of the property awt.button.color to "green". jre accepts any number of -D options on the command line.
- -jar jarfile
- Note: In this release, the -jar option must be used in conjunction with the -new flag:
jre -new -jar ...
Execute a Java program encapsulated in jarfile. Instead of referring to the command line, jre gets the initial class from the jarfile manifest header Main-Class. For example, if the program entry point is COM.MyCompany.MyPackage.MyClass.main(), then this entry must appear in the manifest:
Main-Class: COM.MyCompany.MyPackage.MyClass- -usepolicy[:policyfile]
- Note: In this release, the -usepolicy option must be used in conjunction with the -new flag:
jre -new -usepolicy[:policyfile] ...
Use a security policy. The policy is defined in policyfile, if specified, or in a installation-dependent default if policyfile is not specified.
Without -usepolicy, a Security Manager is not installed, and the program runs without security restrictions.
- -X
- Prints help on non-standard options and exits.
Non-Standard Options
- -Xmxx
- 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 greater than or equal to 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.
- -Xmsx
- 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.
- -Xnoasyncgc
- 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.
- -Xnoclassgc
- Turns off garbage collection of Java classes. By default, the Java interpreter reclaims space for unused Java classes during garbage collection.
- -Xssx
- Each Java thread has two stacks: one for Java code and one for C code. The
-Xss
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 jre has x as its C stack size. The default units for x are bytes. The value of x must be greater than or equal to 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 ("-Xss128k").
- -Xossx
- Each Java thread has two stacks: one for Java code and one for C code. The
-Xoss
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 jre has x as its Java stack size. The default units for x are bytes. The value of x must be greater than or equal to 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 ("-Xoss400k").
- -Xverify
- Performs byte-code verification on the class file.
- -Xverifyremote
- Runs the verifier on all code that is loaded into the system via a classloader. Xverifyremote is the default for the interpreter.
- -Xnoverify
- Turns verification off.
- CLASSPATH
- You can use the CLASSPATH environment variable to specify the path to the class file or files that you want to execute. CLASSPATH consists of a colon-separated list of directories that contain the class files to be executed. For example:
.:/home/xyz/classesIf the file to be executed is azip
file or ajar
file, the path should end with the file name. For example:.:/usr/local/java/classes/MyClasses.jar
CLASSPATH