Complete description of Java command line running parameters — turn

Source: http://xinklabi.iteye.com/blog/837435

When running compiled classes, Java is loaded and executed through the Java virtual machine, which commands Java through the operating system_ Home \ bin \ Java - option to start, and - option is the virtual machine parameter, Java_ Home is the JDK installation path. Through these parameters, the running state of the virtual machine can be adjusted. Mastering the meaning of the parameters can have a deeper understanding of the running mode of the virtual machine.

1、 View parameter list:

2、 Description of basic parameters: 1- The client and - server parameters are used to set the running mode used by the virtual machine. The client mode starts relatively fast, but the runtime performance and memory management efficiency are not as efficient as the server mode. It is usually used for client applications. On the contrary, server mode starts slower than client mode, but can achieve higher performance. On windows, the default virtual machine type is client mode. If you want to use server mode, you need to add the - server parameter when starting the virtual machine to obtain higher performance. For server-side applications, server mode is recommended, especially for systems with multiple CPUs. On Linux and Solaris, the server mode is adopted by default. 2. - hotspot has the same meaning as client, jdk1 4 previously used parameters, jdk1 4. Replace it with client. 3. - classpath, - CP when running a class, the virtual machine needs to load it into memory. The method and order of virtual machine searching for classes are as follows: bootstrap classes, extension classes, user classes. The path in the bootstrap is the jar or zip file that comes with the virtual machine. The virtual machine first searches for these package files and uses system Getproperty ("sun. Boot. Class. Path") can get the package name searched by the virtual machine. Extension is a jar file located in JRE "lib" ext directory. After searching bootstrap, the virtual machine will search the jar file in this directory. Use system getProperty("java.ext.dirs”) You can get the virtual machine search path using extension. The search order of user classes is current directory, environment variable classpath, - classpath. 4. - classpath tells the virtual machine to search the directory name, jar document name and zip document name, with semicolons between them; separate. For example, when you develop a public class and wrap it into a common Jar package, using common Jar, you need to use - classpath common Jar tells the virtual machine to start from common Jar, otherwise the virtual machine will throw Java. Jar Lang.noclassdeffounderror exception, indicating that the class definition was not found. Available at runtime system Getproperty ("Java. Class. Path") gets the path of the virtual machine lookup class.

After using - classpath, the virtual machine will no longer use the class search path in classpath. If - classpath and classpath are not set, the virtual machine will use the current path () As a class search path. It is recommended to use - classpath to define the classpath to be searched by the virtual machine instead of the search path of the environment variable classpath, so as to reduce the potential conflict when multiple projects use classpath at the same time. For example, application 1 uses A1 Class G in 0.jar, application 2 needs to use a2.0 Class G in 0.jar, A2 0. Jar is A1 0.jar upgrade package, when A1 0.jar,a2. 0.jar are all in classpath. When the virtual machine searches for class G in the first package, it will stop searching. If the virtual machines of application 1 and application 2 search from classpath, an application will not get the correct version of class G. 5. - D = value set the attribute name / value pair in the system attribute of the virtual machine, and the application running on the virtual machine can use sy stem Getproperty ("propertyname") gets the value of value. If there are spaces in value, you need to enclose the value in double quotation marks, such as - dName = "space string". This parameter is usually used to set the value of system level global variables, such as configuration file path. This attribute should be accessible anywhere in the program.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>