• 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.


    -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.

    1. -client和-server

    满足不同场合,提供了两种运行模式,一种是server模式,另一种是client模式。
    从jdk1.5以来,当应用程序启动时,如果用户没有在命令行中显式指明虚拟机运行的模式,但启动会自动尝试检查该应用是运行在一个server类型的机器上,还是client类型的机器上。

    2. -cp和-classpath

    设置虚拟机运行的classpath。在该路径(jar或zip文件)下面搜索class文件。如果存在多个路径(jar或zip文件),在windows采用;分隔,在unix采用:作为分隔符。在命令行中指定-classpath或-cp可以覆盖CLASSPATH环境变量的设置。如果没有指定classpath,默认是当前路径。

    3. -D<name>=<value>

    定义运行期变量(或系统属性),功能与环境变量相同
    具体参考博客:https://www.cnblogs.com/lujiango/p/9619524.html

    4. -verbose:

    -verbose:class Java虚拟机运行期间,打印class的加载情况。系统中加载了哪些文件中的哪些类。
    -verbose:gc 打印GC日志
    -verbose:jni 打印详细的JNI本地接口的使用情况

    5. -version和-version<value>

    -version打印当前JDK版本
    -version:1.8以指定版本的虚拟机来运行Java程序

    6. -showversion

    打印jdk的版本,并继续
    java -showversion com.huawei.diagnose.thread.MyTest

    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

    一定使用共享的类数据,否则失败

  • 相关阅读:
    MongoDB入门下
    MongoDB简介
    MongoDB 查询上
    MongoDB 创建,更新,删除文档 下
    MongoDB 创建,更新,删除文档 上
    SqlServer 对 数据类型 text 的操作
    Asp.Net编码
    MongoDB 查询下
    (基于Java)编写编译器和解释器第3A章:基于Antlr构造词法分析器(连载)
    (基于Java)编写编译器和解释器第2章:框架I:编译器和解释器第三部分(连载)
  • 原文地址:https://www.cnblogs.com/lujiango/p/10999745.html
Copyright © 2020-2023  润新知