[Reserved] java virtual machine arguments detailed

In the original text here .

The following excerpt points: 

 

       When you run the compiled Java classes to complete, is to load and execute through the java virtual machine, java virtual machine operating system command JAVA_HOME \ bin \ java -option to start, -option virtual machine parameters, JAVA_HOME is the JDK installation path can be adjusted for running state of the virtual machine by these parameters, to grasp the meaning of the parameters can have a deeper understanding of the mode of operation of the virtual machine.
Virtual machine parameters are divided into basic and extended into two categories, enter the command line JAVA_HOME \ bin \ java can get a list of basic parameters,  at the command line input JAVA_HOME \ bin \ java -X can be extended parameter list .

Basic parameters:


-classpath, -cp
virtual machine when running a class needs to be loaded into memory, the virtual machine mode and order of search categories as follows:

Bootstrap classes,Extension classes,User classes

Bootstrap path in a virtual machine comes with a jar or zip file, the virtual machine first searches the package file, available virtual machine package name search with System.getProperty ( "sun.boot.class.path").

Extension is located in jre \ lib \ jar file in the ext directory, the virtual machine in the search after search completed Bootstrap jar files in that directory. . GetProperty ( "java.ext.dirs") search for available virtual machines paths Extension System.

User classes search order for the current directory, the environment variable CLASSPATH, -classpath.

-classpath inform the virtual machine to search the directory name, jar document name, zip file name, use a semicolon; separated.

For example, when you have developed and packaged as a public class common.jar package, when used common.jar in class, we need to tell the virtual machine -classpath common.jar find the class from common.jar, otherwise the virtual machine java.lang.NoClassDefFoundError will throw an exception, stating that the class definition is not found.

System.getProperty available at runtime ( "java.class.path") get path to the virtual machine looks for classes.


-Classpath using the virtual machine will not be used in the CLASSPATH class search path, if the CLASSPATH and -classpath are not set, then the virtual machine uses the current path (.) As a category search path .

-Classpath is recommended to define the class path of the virtual confidential search, rather than using a search path environment variable CLASSPATH to reduce potential conflicts exist when multiple projects simultaneously CLASSPATH. Application example 1 To use a1.0.jar classes G, 2 applications to use a2.0.jar classes G, a2.0.jar a1.0.jar upgrade package is, when a1.0.jar , a2.0.jar in the CLASSPATH, the virtual machine is stopped when a package searched first search class G, if an application virtual machines 2 are applied from the CLASSPATH searches, you will not have an application the correct version of the class G.


-D<propertyName>=value

Attribute name attribute set in the virtual machine system / value pairs, an application running on the virtual machine available System.getProperty ( "propertyName") value of the value obtained.
If there are spaces in value, you need to use the value enclosed in double quotation marks , as -Dname = "space string".
This parameter is typically used to set the global variable level system, such as a profile path, should be accessible from anywhere in the program for this property.


-version
show version information for the virtual machine can run and then exit. When equipped with different versions of the JDK on a single machine


-Xms <size>
set the initial size, the default units of the virtual machine heap memory available in bytes, the size of an integer multiple of 1024 and greater than 1MB, available k (K) or m (M) is set larger units the amount of memory. The initial heap size is 2MB.
For example: -Xms6400K, -Xms256M


-Xmx <size>
set the virtual machine heap memory available maximum size, in bytes default. The value must be an integer multiple of 1024, and greater than 2MB. Available k (K) or m (M) as a unit to set a large number of memory. The default heap maximum of 64MB.
For example: -Xmx81920K, -Xmx80M
when the application is filed for a virtual machine throws java.lang.OutOfMemoryError large memory runtime: Java heap space error, you need to use -Xmx set a large heap of available memory.


-Xss <size>
set the thread stack size, default bytes. And -Xmx Similarly, K or M can also be set to a large value. Usually assigned to the operating system's default thread stack size is 1MB.
In addition the size of the stack may also be provided, a thread is created constructor prototype for an object in java Thread (ThreadGroup group, Runnable target, String name, long stackSize).

Guess you like

Origin www.cnblogs.com/tlz888/p/12218856.html