Java command parameter description

Source: Internet
Author: User
Tags bootstrap classes

 

When running compiled classes, Java is loaded and executed through the Java Virtual Machine.
The system command java_home \ bin \ Java-option is enabled.-option is the virtual machine parameter, and java_home is JDK.
Installation path. You can adjust the running status of the virtual machine through these parameters.
The row mode has a deeper understanding.
 
1. view the parameter list:

Virtual Machine Parameters are classified into two types: basic and extension. Enter java_home \ bin \ Java in the command line to obtain the basic parameters.
List,

Enter java_home \ bin \ Java-X in the command line to obtain the extended parameter list.

Ii. Basic parameter description:

1.-client,-Server

These two parameters are used to set the running mode used by the virtual machine. The client mode is faster to start, but the runtime performance and
Memory Management is less efficient than server mode, which is usually used for client applications. Program . On the contrary, the server mode is better than the client
Slow, but can achieve higher running performance.

In Windows, the default Virtual Machine Type is client mode. To use server mode, you must start
The-server parameter is added to the virtual machine to achieve higher performance. For server-side applications, the server mode is recommended, especially
It is a system with multiple CPUs. In Linux, Solaris adopts the server mode by default.


2.-hotspot

The meaning is the same as that of the client. The parameter jdk1.4 previously used is no longer used and replaced by the client.


3.-classpath,-CP
When a virtual machine runs a class, it needs to be loaded into the memory. The method and sequence of the Virtual Machine search class are as follows:

Bootstrap classes, extension classes, and user classes.

The path in Bootstrap is the jar or ZIP file that comes with the VM. The VM first searches for these package files and uses
System. getproperty ("Sun. boot. Class. Path.

Extension is a jar file located in the JRE \ Lib \ ext directory. The VM searches for the JAR file after searching for bootstrap.
. Use System. getproperty ("Java. Ext. dirs") to obtain the virtual machine usage.
Extension search path.

The user classes search order is the current directory, environment variable classpath, and-classpath.


4.-classpath
Tell the virtual machine to search for the directory name, JAR file name, and zip file name, separated by semicolons.

For example, if you develop a public class and package it into a common. jar package
You need to use-classpath common. jar to tell the virtual machine to find the class from common. jar; otherwise, the virtual machine will throw
An exception occurs in Java. Lang. noclassdeffounderror, indicating that the class definition is not found.

You can use system. getproperty ("Java. Class. Path") at runtime to obtain the path of the Virtual Machine search class.


After-classpath is used, the virtual machine no longer uses the Class search path in classpath. If-classpath and
If no classpath is set, the VM uses the current path (.) as the class search path.

We recommend that you use-classpath to define the path of the class to be searched by the VM, instead of using the search environment variable classpath.
To reduce potential conflicts when multiple projects use classpath at the same time. For example, application 1 needs to use
Class G in a1.0.jar, Application 2 must use Class G in a2.0.jar, and a2.0.jar is the upgrade package of a1.0.jar. When
Both a1.0.jar and a2.0.jar are in classpath. When the VM finds the class G in the first package, it stops searching,
If the virtual machines of Application 1 and Application 2 are searched from classpath, a class G with the correct version of the application cannot be obtained.


5.-D <propertyname> = Value
Set the attribute name/value pair in the system attribute of the Virtual Machine. applications running on the virtual machine are available.


This parameter can be used to diagnose the situation of loading a virtual machine from a class if the reporting class of the virtual machine cannot be found or the class conflict occurs.


7.-verbose: GC
When the VM memory is recycled, the output device is displayed in the following format:

[Full GC 268 K-> 168 K (1984 K), 0.0187390 secs]

This parameter is used to monitor the recovery of VM memory.


8.-verbose: JNI
When the virtual machine calls the native method, the output device information is displayed in the following format:

[Dynamic-linking native method hellonative. Sum... JNI]

This parameter is used to monitor Virtual Machine calls to local methods. It can be conveniently diagnosed when a JNI error occurs.


9.-version
Display the version of the virtual machine that can be run and exit. When a machine is installed with JDK of different versions


10.-showversion
Displays version information and help information.


11.-ea [: <packagename>... |: <classname>]
12.-enableassertions [: <packagename>... |: <classname>]

JAVA supports the assertion mechanism from jdk1.4 to diagnose runtime problems. Usually make the assertions valid in the test phase,
You do not need to run assertions during formal operation. The expression value after assertion is a logical value. If it is true, the assertion does not run,
If this parameter is set to false, a java. Lang. assertionerror error is thrown.

The above parameters are used to set whether the VM starts the assertion mechanism. If there is a shortage of time-saving VMS, the assertion mechanism is disabled and enabled using-ea.
<Packagename> and classname are not added to the assertion mechanism.
Some assertions in the package or class can be added to the package name or class name after-ea. For example, to enable the disconnection in the com. Foo. util package
Command-Ea: COM. Foo. util.


13.-Da [: <packagename>... |: <classname>]
14.-disableassertions [: <packagename>... |: <classname>]

Set the VM to disable assertion processing. packagename and classname are used in the same way as-ea.
 
 
15.-ESA |-enablesystemassertions
Sets the virtual machine to display system-class assertions.
 
 
16.-DSA |-disablesystemassertions
Set the VM to disable system-class assertions.
 
 
17.-agentlib: <libname> [= <Options>]
This parameter is newly introduced by jdk5. it is used to load the local proxy library on a virtual machine.
 
Libname is the name of the local proxy library file, the virtual machine search path is the path in the environment variable path, and options is passed
Parameters for local database startup. Multiple parameters are separated by commas. Search for the local database name on a virtual machine on Windows
For libname. DLL files, search for files with the local library name libname. So on UNIX, and search for path loops.
Environment variables vary on different systems. For Linux, SunOS, and Irix, LD_LIBRARY_PATH is used, and for Aix, libpath is used,
Shlib_path on the HP-UX

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.