JRE & JDK: Java Runtime Environment (JRE)

Components of the Java Runtime Environment

Overview

We don’t need the full JDK to run a Java application that’s already been compiled from source code; all we need is the Java Runtime Environment (JRE). The JRE contains tools for launching Java applications, the Java Virtual Machine (JVM) that executes Java Bytecode, and the standard Java Class Library (JCL).

Runtime tools

java: Application launcher

This is the command used to start a Java application.

Syntax (module-oriented alternatives not included)

java [options] <mainclass> [args...]
java [options] -jar <jarfile> [args...]
java [options] <sourcefile> [args]

options (subset)

--help, -help, -h, -?

Displays information on available options.

-version, --version

Displays version information.

--class-path <path>, -classpath <path>, -cp <path>

Specifies the classpath—one or more directories, separated by semicolons on Windows and colons on OS X and Linux, in which the compiler will search for referenced classes. (Not valid in JAR mode.)

-D<property>=<value>

Sets the specified system property to the specified value. This may be a predefined system property (e.g. user.language, java.version, os.name), in which case this option can be used to override the default value of such a property; if not, then this defines a custom property and supplies a value. In either case, the value of a system property can be accessed at runtime via the System.getProperty method.

Arguments

mainclass

Entry point of application.

jarfile

JAR file containing main class, and any supporting classes not referenced in the class-path attribute of the manifest. The main class must be referenced by a main-class attribute of the manifest.

args

Zero or more arguments passed (as a String[], or array of String object references) to the main method of mainclass by the application launcher.

Simplified operation diagram

Java application launcher (`java`) diagram