JVM命令行參數

root@ubuntu-blade2:/sdf/jdk# java
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server,
because you are running on a server-class machine.html


-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
Warning: this feature is deprecated and will be removed
in a future release.
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
Warning: this feature is deprecated and will be removed
in a future release.
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.java

1. -client和-server

知足不一樣場合,提供了兩種運行模式,一種是server模式,另外一種是client模式。
從jdk1.5以來,當應用程序啓動時,若是用戶沒有在命令行中顯式指明虛擬機運行的模式,但啓動會自動嘗試檢查該應用是運行在一個server類型的機器上,仍是client類型的機器上。bootstrap

2. -cp和-classpath

設置虛擬機運行的classpath。在該路徑(jar或zip文件)下面搜索class文件。若是存在多個路徑(jar或zip文件),在windows採用;分隔,在unix採用:做爲分隔符。在命令行中指定-classpath或-cp能夠覆蓋CLASSPATH環境變量的設置。若是沒有指定classpath,默認是當前路徑。ubuntu

3. -D<name>=<value>

定義運行期變量(或系統屬性),功能與環境變量相同
具體參考博客:https://www.cnblogs.com/lujiango/p/9619524.htmlwindows

4. -verbose:

-verbose:class Java虛擬機運行期間,打印class的加載狀況。系統中加載了哪些文件中的哪些類。
-verbose:gc 打印GC日誌
-verbose:jni 打印詳細的JNI本地接口的使用狀況併發

5. -version和-version<value>

-version打印當前JDK版本
-version:1.8以指定版本的虛擬機來運行Java程序oracle

6. -showversion

打印jdk的版本,並繼續
java -showversion com.huawei.diagnose.thread.MyTestapp

7. -jre-restrict-search | -jre-no-restrict-search

在版本搜索中包含/排除用戶私有JRE函數

8 -? -help

打印幫助信息性能

9. -X

打印擴展(即-X參數)幫助

10. -ea[:<packageName>...|:<className>]和-enableassertion[:<packageName>...|:<className>]

激活斷言,默認狀況爲禁止,若是沒有跟參數,則標示激活全部斷言。若是跟隨參數,則標示僅對指定的包或類激活斷言。若是跟隨的參數是「...」,則標示只激活當前工做目錄下面的未命名包的斷言。若是不是以「...」爲結尾,則表示激活指定類中的斷言。
若是一個命令行中包含多個選項(即多個-ea或-enableassertions),則以加載這些類的順序爲準。
激活com.wombat.fruitbat包中的斷言,命令以下:
java -ea:com.wombat.fruitbat... <>

11. -da[:<packagename>...|:<classname>]和-disableassertions[:<packagename>...|:<classname>]

關閉斷言(默認也是關閉)

12. -esa | -enablesystemassertions

激活全部系統類中的斷言(即設置系統類的缺省斷言狀態爲true)

13. -dsa | -disablesystemassertions

禁止全部系統類中的斷言(即設置系統類的缺省斷言狀態爲false)

14. -agentlib:<libname>[=<options>]

加載本地代理庫
-agentlib:hprof
-agentlib:jdwp=help
-agentlib:hprof=help

15. java -X擴展運行參數

root@ubuntu-blade2:/opt# java -X
-Xmixed mixed mode execution (default)
-Xint interpreted mode execution only
-Xbootclasspath:<directories and zip/jar files separated by :>
set search path for bootstrap classes and resources
-Xbootclasspath/a:<directories and zip/jar files separated by :>
append to end of bootstrap class path
-Xbootclasspath/p:<directories and zip/jar files separated by :>
prepend in front of bootstrap class path
-Xdiag show additional diagnostic messages
-Xnoclassgc disable class garbage collection
-Xincgc enable incremental garbage collection
-Xloggc:<file> log GC status to a file with time stamps
-Xbatch disable background compilation
-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
-Xss<size> set java thread stack size
-Xprof output cpu profiling data
-Xfuture enable strictest checks, anticipating future default
-Xrs reduce use of OS signals by Java/VM (see documentation)
-Xcheck:jni perform additional checks for JNI functions
-Xshare:off do not attempt to use shared class data
-Xshare:auto use shared class data if possible (default)
-Xshare:on require using shared class data, otherwise fail.
-XshowSettings show all settings and continue
-XshowSettings:all
show all settings and continue
-XshowSettings:vm show all vm related settings and continue
-XshowSettings:properties
show all property settings and continue
-XshowSettings:locale
show all locale related settings and continue

The -X options are non-standard and subject to change without notice.

15.1 -Xmixed

混合模式執行(默認),即解釋模式和JIT混合執行。

15.2 -Xint

解釋模式執行。禁止將類中的方法編譯成本地代碼,全部的字節碼以解析方式進行。

15.3 -Xbootclasspath:<directories and zip/jar files separated by ;>

將路徑,jar,zip庫加增長到啓動class的搜索路徑,以";"做爲分隔符。

15.4 -Xbootclasspath/a:<directories and zip/jar files separated by ;>

將路徑,jar,zip庫加增長到缺省的bootclasspath,以";"做爲分隔符。

15.5 -Xbootclasspath/p:<directories and zip/jar files separated by ;>

將路徑,jar,zip庫加增長到缺省的bootclasspath的前面,以";"做爲分隔符。注意,應用程序使用該命令的目的是爲了覆蓋rt.jar中的類。

15.6 -Xnoclassgc

不進行class的垃圾收集

15.7 -Xincgc

打開增量垃圾收集增量。垃圾收集開關在缺省狀況下是關閉的。增量垃圾收集能夠減小程序運行期偶發的長時間垃圾收集。增量垃圾收集器將在必定的時間與程序併發執行,在這段垃圾收集的時間內,對正在執行的程序有必定的性能影響。

15.8 -Xloggc:<file>

將GC信息打印到指定的文件中。與-verbose:gc相似,-Xloggc:<file>將GC信息中直接打印到一個文件中。若是兩個都提供了,那麼以-Xloggc:<file>爲準。

15.9 -Xbatch

關閉後臺編譯。正常狀況下,JVM將之後臺的方式編譯class中的方法,一直按解析模式運行代碼,直到後臺編譯完成。-Xbatch標記關閉後臺編譯,全部方法的編譯做爲前臺任務完成,直到編譯完成。

15.10 -Xms<size>

指明堆內存的初始大小。該值必須是1024的倍數,而且大於1MB. 能夠經過k或者M後綴表示是以KB字節爲單位,m或者M表示以MB字節爲單位。
-Xms6291456
-Xms6144k
-Xms6m

15.11 -Xmx<size>

指明最大的堆內存大小,該值必須是1204字節的倍數,k或者K表示KB, m或者M表示MB.
-Xmx83886080
-Xmx81920k
-Xmx80m

15.12 -Xss<size>

設置線程堆棧的大小。

15.13 -Xprof

打開CPU剖析功能。

15.14 -Xfuture

執行嚴格的類文件格式檢查。-Xfuture選項打開,將執行更嚴格的類文件格式檢查,這樣能夠確保類文件與標準中定義的類文件格式更加順從。

15.15 -Xrs

減小由JVM使用的操做系統信號量。

15.16 -Xcheck:jni

對JNI函數執行附加的檢查特別地,虛擬機在處理JNI請求以前,會對傳給JNI調用的參數進行校驗,同時對運行期環境數據也進行校驗。

15.17 -Xshare:off

關於使用共享類數據。

15.18 -Xshare:auto

在可能的狀況下,使用共享的類數據

15.19 -Xshare:on

必定使用共享的類數據,不然失敗

相關文章
相關標籤/搜索