# jre - The Java Runtime Interpreter (Win32)

> jre interprets (executes) Java bytecodes.

## SYNOPSIS

       jre [ options ] classname <args>
       jrew [ options ] classname <args>

## DESCRIPTION

> The jre command executes Java `class` files. The jrew command is identical to jre, except that with jrew there is no associated console window. Use jrew when you don't want a command prompt window to appear.

> The `classname` argument is the name of the class file to be executed. Any arguments to be passed to the class must be placed after the `classname` on the command line. On Windows platforms, the jre tool ignores the CLASSPATH environment variable. The `-cp` option should be used to specify an application's class path.

## USING THE JIT

> By default, each class file is compiled to native code by a Just In Time bytecode compiler, or JIT. Using the JIT can cause some delay in program startup and class file loading, but can also reduce overall program execution time by a factor of ten.

> On Windows, jre ignores the environment variable JAVA_COMPILER. To disable the JIT, use the `-nojit` option. To use an alternate JIT, use the `-D` option to set the `java.compiler` property. The launcher appends `.DLL` to the property value, then searches for the resulting filename. The search begins in the executable directory (the same directory that contains `JRE.EXE`), and continues with all directories in the `PATH`. For example:

>         jre -Djava.compiler=myjit MyClass

## OPTIONS

-classpath path(s)
  Specifies the path or paths that jre uses to look up classes. Overrides the default classpath set in the registry. If more than one path is specified, they must be separated by semicolons. 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` or `jar` file, the path to that file must end with the file's name. Here is an example of an argument for `-classpath` consisting of two paths:

         C:\xyz\classes;C:\usr\local\java\classes\MyClasses.jar

-cp path(s)
  Prepends the specified path or paths to the base classpath that jre uses to look up classes. If more than one path is specified, they must be separated by semicolons. Each path should end with the directory containing the class file(s) to be executed. However, if a file to be executed is a <cocd>zip or `jar` file, the path to that file must end with the file's name. Here is an example of an argument for `-cp` consisting of two paths:

         C:\xyz\classes;C:\usr\local\java\classes\MyClasses.jar

-help
  Print a usage message.

-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 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.

-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.

-noclassgc
  Turns off garbage collection of Java classes. By default, the Java interpreter reclaims space for unused Java classes during garbage collection.

-nojit
  Don't invoke the Just In Time bytecode compiler. The virtual machine directly interprets bytecodes, without converting them to native code.

-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 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 ("-ss128k").

-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 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 ("-oss400k").

-v, -verbose
  Causes jre to print a message to stdout each time a class file is loaded.

-verify
  Performs byte-code verification on the class file. Beware, however, that java -verify does not perform a full verification in all situations. Any code path that is not actually executed by the interpreter is not verified. Therefore, java -verify cannot be relied upon to certify class files unless all code paths in the class file are actually run.

-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.

-D propertyName=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.

### Options for Control of Heap Expansion and Shrinkage

The following options, introduced in version 1.1.8 of the Java Development Kit, allow for user control of garbage-collected heap expansion and shrinkage. The default settings of the heap expansion and shrinkage parameters are appropriate for the majority of applications, so these options are not needed in most computing situations. You should not use them unless you understand the effect they will have on your application. Randomly setting these options is as likely to decrease the performance of your system as improve it. The effect of these options will be greatest if a JIT compiler is not being used. See also the heap shrinkage limitations below.

-maxe size
  Sets the maximum size of each expansion of the heap when more memory is required. By default, size is measured in bytes. To specify size in either kilobytes or megabytes, append "k" for kilobytes or "m" for megabytes. The default value for the setting of maxe is 2 megabyte of memory. Example:

  >     java -maxe2097152 MyClass

-mine size
  Sets the minimum size of each expansion of the heap. Also sets the minimum size of free object space in the heap. The heap will be returned to the OS only when the amount of free object space in the heap space is more than the setting of mine. By default, size is measured in bytes. To specify size in either kilobytes or megabytes, append "k" for kilobytes or "m" for megabytes. The default value for mine is 1 megabyte of memory. Example:

  >     java -mine1048576 MyClass

-maxf float
  Sets the approximate percentage of maximum free heap. If the percentage of free object space in the heap is more than the setting of maxf and the amount of free object space in the heap is more than the setting of mine, and free object space is located at the top of the heap, the garbage collector will attempt to shrink the heap by returning a portion of free object space back to the OS. The heap size will not shrink below its initial size. The default value for maxf is 1.00; by default no heap is returned back to the OS. Example:

  >     java -maxf0.60 MyClass

-minf float
  Sets the approximate percentage of minimum free space in the heap to give control over the rate of preallocation performed when heap space is expanded. After expansion, approximately minf percent of the heap should be free. The actual amount of free space in the space after expansion is dependent on the value of minf and fragmentation of free spaces within the heap. The default value for minf is 0.25. Example:

  >     java -minf0.35 MyClass

Heap Shrinkage Limitations: The amount heap shrinkage relies on using heap compaction to free up space at the end of the heap which is then de-committed to return it to the OS. The Java garbage collector is implemented using a compacting, mark-sweep collector with some conservative scanning. A gc is conservative if it does not collect memory that looks as if it might be in use on the stack or in registers.

The mark-sweep and conservative scanning phase of the garbage collector marks objects as being free, used and un-movable (pinned), or used and movable. After the objects have been marked, free space is garbage collected. The compacting phase of the garbage collector attempts to coalesce the movable objects to the low end of object space to reduce heap fragmentation.

If an object is un-movable (pinned), it cannot be moved during the compaction phase. If one of the pinned objects is near the top of the heap, and much of the free space is below it, the free space below the pinned object cannot be returned to the OS. If either the JIT compiler is enabled, or the Java Native Interface (JNI) API or native method interface is used to make C calls, the conservative scan phase of the garbage collector may see a value in memory created by the C code that looks like a pointer to an object and mark the object in the heap as "pinned" because it appears to be pointed to directly by native code.

## SEE ALSO

> java