Oom was encountered during system upgrade some time ago. For details about the solution, see outofmemoryerror;
To consolidate the knowledge of various Java startup parameters, we decided to list all the parameters and explain them one by one for further query;
Java startup parameters are divided into three types;
FirstStandard Parameters(-), All JVM implementations must implement these parameter functions and are backward compatible;
SecondNon-standard parameters(-X). By default, JVM implements the functions of these parameters, but not all JVM implementations are satisfied, and backward compatibility is not guaranteed;
ThirdNon-stable parameter(-Xx). The implementation of such parameters varies with JVM, and may be canceled at any time in the future. You must use this parameter with caution;
This article mainly describes the standard parameters, and the remaining two parts will be released one after another;
The standard parameter list is as follows:
-Client
Setting JVM to use the client Mode features Fast startup, but low performance and memory management efficiency during runtime. It is usually used for development and debugging of client applications or PC applications.
-Server
Set the JVM to enable the server mode. It features a slow startup speed, but high runtime performance and memory management efficiency, and is suitable for the production environment. This mode is enabled by default in a 64-bit JDK environment, while the-client parameter is ignored.
-Agentlib: libname [= options]
Used to load the local lib package;
Here, libname is the name of the local agent library, and the default search path is the path in the environment variable path. options is the parameter passed to the local database at startup. Multiple parameters are separated by commas. On the Windows platform, JVM searches for the local database named libname. DLL file, in Linux JVM search local library name libname. so files, search PATH environment variables vary on different systems, for example, solaries, LD_LIBRARY_PATH is searched by default.
For example:-agentlib: hprof
It is used to obtain the JVM running status, including CPU, memory, thread, and other running data, and can be output to a specified file. In Windows, the search path is jre_home/bin/hprof. dll.
-Agentpath: pathname [= options]
Load the local library by full path without searching the path in path. Other functions are the same as those in agentlib. More information is to be continued and will be detailed in the subsequent jvmti sections.
-Classpath
-CP classpath
Inform JVM of the directory name, JAR file name, and zip file name to be searched by semicolons (;). After-classpath is used, JVM will no longer use the Class search path in classpath, if neither-classpath nor classpath is set, the JVM uses the current path (.) as the Class search path.
The methods and sequence of JVM search classes are bootstrap, extension, and user.
The path in Bootstrap is a jar or ZIP file that comes with JVM. JVM first searches for these package files and obtains the search path using system. getproperty ("Sun. boot. Class. Path.
Extension is a jar file located in the jre_home/lib/EXT directory. After JVM searches for bootstrap, it searches for the JAR file in this directory, using system. getproperty ("Java. ext. dirs ") to obtain the search path.
The user search order is the current path., classpath, and-classpath. The JVM finally searches for these directories and uses system. getproperty ("Java. Class. Path") to obtain the search path.
-Dproperty = Value
Set the system property name/value pair. The application running on this JVM can obtain the value of value through system. getproperty ("property.
If the value contains spaces, double quotation marks are required to enclose the value, such as-dname = "Space string ".
This parameter is usually used to set system-level global variable values, such as the configuration file path, so that this attribute can be accessed anywhere in the program.
-Enableassertions [: <package name> "..." |: <Class Name>]
-Ea [: <package name> "..." |: <Class Name>]
The above parameters are used to set whether the JVM starts the asserted mechanism (supported since JDK 1.4). The JVM does not have time to disable the asserted mechanism.
You can use-ea to enable the assertion mechanism without <packagename> and classname. If you want to run only the assertion in some packages or classes, you can add the package name or class name to-ea. For example, to start the assertions in the package com. Wombat. fruitbat, run Java-Ea: COM. Wombat. fruitbat... <main class>.
-Disableassertions [: <package name> "..." |: <class;]
-Da [: <package name> "..." |: <Class Name>]
It is used to set JVM to disable assertion processing. packagename and classname are used in the same way as-ea, and JVM is disabled by default.
This parameter is generally used in scenarios where certain classes in the same package do not need to be asserted, such as COM. wombat. fruitbat requires assertions, But Com. wombat. fruitbat. if the brickbat class is not required, run the following command:
Java-Ea: COM. Wombat. fruitbat...-da: COM. Wombat. fruitbat. brickbat <main class>.
-Enablesystemassertions
-ESA
Activate system class assertions.
-Disablesystemassertions
-DSA
Disable system class assertions.
-Jar
Specifies to execute an application in the form of a jar package.
To execute an application in this way, you must declare the initial loaded main-class in the manifest file of the jar package. Of course, the main-class must have public static void main (string [] ARGs) method.
-Javaagent: jarpath [= options]
Specify the JVM startup fashion to the Java language device proxy.
The mainfest file in the jarpath file must have the agent-class attribute. The proxy class must also implement the public static void premain (string agentargs, instrumentation insT) method (similar to the main method ). During JVM initialization, The premain method is called in the order described by the proxy class. For details, see the description of Java. Lang. Instrument Software Package.
-Verbose
-Verbose: Class
Output Information about the JVM loaded class. This can be diagnosed when the JVM report says no class or class conflict is found.
-Verbose: GC
Output related information about each GC.
-Verbose: JNI
Outputs Information about native method calls. It is generally used to diagnose JNI call errors.
-Version
Output the Java version information, such as the JDK version, vendor, and model.
-Version: Release
Specifies the JDK version information required for running the class or jar. If the specified version is not found, it is executed in the default JDK version that can be found. Generally, for jar files, you can specify the required version information in the manifest file instead of the command line.
In release, you can specify a single version or a list separated by spaces. complex combinations are supported, such:
-Version: "1.5.0 _ 04 1.5 * & 1.5.1 _ 02 +"
The specified class or jar must be of version 1.5.0 _ 04 or later than 1.5.1 _ 02 in the 1.5 series.
-Showversion
After the Java version information is output (the same as-version), the java standard parameter list and its description are output.
-?
-Help
Output the java standard parameter list and its description.
-X
Output a list of non-standard parameters and their descriptions.
We often use multiple combinations of the above parameters in many cases. For example, when we use jprofiler for tracking and monitoring, we need to add the following configuration in the monitored Java startup parameters:
-Agentlib: jprofilerti = Port = 8849-xbootclasspath/A:/usr/local/jprofiler5/bin/agent. Jar
Two-agentlib and-x parameters are used. The detailed information of the bootclasspath parameter is described in non-standard parameters.