Running Java applications

Java™ applications can be started using the java launcher or through JNI. Settings are passed to a Java application using command-line arguments, environment variables, and properties files.

Purpose

The java and javaw tools start a Java application by starting a Java Runtime Environment and loading a specified class.

On AIX, Linux, and Windows systems, the javaw command is identical to java, except that javaw has no associated console window. Use javaw when you do not want a command prompt window to be displayed. The javaw launcher displays a window with error information if it fails.

On z/OS systems, the javaw command is identical to java, and is supported on z/OS® for compatibility with other platforms.

Note: On Windows systems, a process has two code pages: the ANSI (or Windows) code page and the OEM (or DOS) code page. By default, javaw uses the ANSI code page whereas java, launched from the command prompt, typically uses the OEM code page. Use the -Dconsole.encoding property to specify the code page to use for output from the java or javaw command. For example, -Dconsole.encoding=Cp1252 causes all output to be in the Windows ANSI Latin1 code page (1252).

Usage

The JVM searches for the initial class (and other classes that are used) in three sets of locations: the bootstrap class path, the installed extensions, and the user class path. The arguments that you specify after the class name or .jar file name are passed to the main function.

The java and javaw commands have the following syntax:
java [options] <class> [arguments]
java [options] -jar <file.jar> [arguments]
javaw [options] <class> [arguments]
javaw [options] -jar <file.jar> [arguments]

Parameters

[options]
Command-line options to be passed to the runtime environment.
<class>
Startup class. The class must contain a main() method.
<file.jar>
Name of the .jar file to start. It is used only with the -jar option. The named .jar file must contain class and resource files for the application, with the startup class indicated by the Main-Class manifest header.
[arguments]
Command-line arguments to be passed to the main() function of the startup class.