java 参数

参考 http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html#Options

 

java 命令行运行的语法如下:

java [ options ] class [ arguments ]

java [ options ] -jar file.jar [ arguments ]

这里记录 options 可以使用的选项

 

对于 boolean 型 options, -X:+<option> 表示打开,-XX:-<option> 表示关闭

对于 numeric 型 options, -X:<option>=<number>, number 可以包含 k,K,m,M,g,G 表示 KB,MB,GB

对于 string 型 options,  -X:<option>=<string>

 

标准 options (无前缀)
-client 以 client 模式运行 java 程序
-server 以 server 模式运行 java 程序

client / server 模式说明:

  client 模式启动速度快,适合桌面应用

  server 模式启动速度慢一点,但运行速度快,适合服务器使用

-classpath classpath

-cp classpath

指定 class path
-Dproperty=value 设定系统参数
-jar 指定要执行的 jar 文件
-javaagent:jarpath[=options]

加载 java 代理

https://docs.oracle.com/javase/7/docs/api/java/lang/instrument/package-summary.html

-agentlib:libname[=options]

加载本地代理库

https://docs.oracle.com/javase/7/docs/platform/jvmti/jvmti.html#starting

-agentpath:pathname[=options] 本地代理库路径

-verbose

-verbose:class

-verbose:gc

-verbose:jni

列出详细信息

列出加载的类

显示GC信息

显示JNI信息

-splash:imagepath 指定启动画面
非标准 options(-X前缀,不稳定)
-X 显示支持的非标准 options
-Xint 解释执行模式
-Xbatch 禁用后台编译 
-Xbootclasspath:bootclasspath

指定用 ; 分隔的目录和 zip/jar 文件

设置搜索路径以引导类和资源

-Xbootclasspath/a:path

指定用 ; 分隔的目录和 zip/jar 文件

附加在引导类路径末尾

-Xbootclasspath/p:path

指定用 ; 分隔的目录和 zip/jar 文件

置于引导类路径之前

-Xcheck:jni 对 JNI 函数执行额外的检查
-Xfuture 执行严格的 class 文件格式检查 
-Xnoclassgc 禁用垃圾收集 
-Xincgc 启用增量垃圾收集 
-Xloggc:file 将 GC 状态记录在文件中 (带时间戳) 
-Xprof 输出 cpu 配置文件数据
-Xrs 减少 java vm 使用的操作系统信号 
-Xverify:mode 设置 bytecode 验证器的模式 
-Xmnn 设置新生代的大小 
-Xmsn 堆的初始大小
-Xmxn 堆的最大大小
-Xssn 线程栈大小
-XX:PermSize=n 永久区初始大小
-XX:MaxPermSize=n 永久区最大大小
-XX:NewRatio=n 老年代 / 新生代 的比例,默认是 2
-XX:Newsize=n 设置新生代的大小
-XX:SurvivorRatio=n Eden/Survivor 的比例,默认是 8
-XX:PretenureSizeThresHold 直接晋升到老年代的对象的大小,设置这个参数后,大于这个参数的对象将直接在老年代分配
-XX:MaxTenuringThreshold=n 晋升到老年代的对象年龄。每个对象在坚持过一次 Minor GC 后,年龄加 1,当超时这个参数值时就进入老年代,默认值是 15
-XX:+HandlePromotionFailure 是否允许分配担保失败,即老年代的剩余空间不足以应付新生代的整个 Eden 和 Survivor 区的所有对象都存活的极端情况
-XX:UseAdaptiveSizePolicy 动态调整 Java 堆中各个区域的大小以及进入老年代的年龄
GC 相关 Options
-XX:-DisableExplicitGC 禁用显式的垃圾收集,设置这个选项后, System.gc() 无效
-XX:-UseConcMarkSweepGC 使用 ParNew + CMS + Serial Old 组合进行内存回收。Serial Old 收集器将作为 CMS 收集出现 Concurrent Mode Failure 失败后的后备收集器使用
-XX:-UseParallelGC 使用 Parallel Scavenge + Serial Old(PS MarkSweep) 的组合进行内存回收
-XX:-UseParallelOldGC 使用 Parallel Scavenge + Parallel Old 组合进行内存回收
-XX:-UseParNewGC 使用 ParNew + Serial Old 收集器进行内存回收
-XX:-UseSerialGC 使用 Serial + Serial Old 收集器进行内存回收
-XX:-UseG1GC 使用 G1
-XX:GCTimeRatio GC 时间占总时间的比率,默认值是 99,即允许 1% 的 GC 时间。仅在使用 parallel Scavenge 收集器时有效
-XX:MaxGCPauseMillis=n 设置 GC 的最大停顿时间。仅在使用 Parallel Scavenge 收集器时有效
   
-XX:CMSInitiatingOccupancyFraction=n 设置 CMS 收集器在老年代空间被使用多少后触发垃圾收集。默认值是 68%。仅在使用 CMS 收集器时生效
-XX:+UseCMSCompactAtFullCollection 设置 CMS 收集器在完成垃圾收集后是否启动一次内存碎片整理。仅在使用 CMS 收集器时生效。 1.8 中过期
-XX:CMSFullGCsBeforeCompaction=n 设置 CMS 收集器在进行若干次垃圾收集后再启动一次内存碎片整理。仅在使用 CMS 收集器时生效。 1.8 中过期
   
-XX:InitiatingHeapOccupancyPercent=n 触发并发垃圾收集周期的整个堆空间的占用比例。它被垃圾收集使用,用来触发并发垃圾收集周期,基于整个堆的占用情况,不只是一个代上(比如:G1)。0值 表示’do constant GC cycles’。默认是45
-XX:ParallelGCThreads=n 设置并行 GC 时,进行内存回收的线程数
-XX:ConcGCThreads=n 并发垃圾收集器使用的线程数量,默认值根据Java虚拟机运行的平台有所变化
-XX:G1ReservePercent=n 为了降低晋升失败机率设置一个假的堆的储备空间的上限大小,默认值是10
-XX:G1HeapRegionSize=n 使用G1收集器,Java堆被细分成一致大小的区域。这设置个体的细分的大小。这个参数的默认值由工学意义上的基于堆的大小决定
调试类
-XX:-CITime Prints time spent in JIT Compiler. (Introduced in 1.4.0.)
-XX:ErrorFile=./hs_err_pid<pid>.log If an error occurs, save the error data to this file. (Introduced in 6.)
-XX:HeapDumpPath=./java_pid<pid>.hprof Path to directory or filename for heap dump. Manageable. (Introduced in 1.4.2 update 12, 5.0 update 7.)
-XX:-HeapDumpOnOutOfMemoryError Dump heap to file when java.lang.OutOfMemoryError is thrown. Manageable. (Introduced in 1.4.2 update 12, 5.0 update 7.)
-XX:OnError="<cmd args>;<cmd args>" Run user-defined commands on fatal error. (Introduced in 1.4.2 update 9.)
-XX:OnOutOfMemoryError="<cmd args>; 
<cmd args>"
Run user-defined commands when an OutOfMemoryError is first thrown. (Introduced in 1.4.2 update 12, 6)
-XX:-PrintClassHistogram Print a histogram of class instances on Ctrl-Break. Manageable. (Introduced in 1.4.2.) The jmap -histo command provides equivalent functionality.
-XX:-PrintConcurrentLocks Print java.util.concurrent locks in Ctrl-Break thread dump. Manageable. (Introduced in 6.) The jstack -l command provides equivalent functionality.
-XX:-PrintCommandLineFlags Print flags that appeared on the command line. (Introduced in 5.0.)
-XX:-PrintCompilation Print message when a method is compiled.
-XX:-PrintGC Print messages at garbage collection. Manageable.
-XX:-PrintGCDetails Print more details at garbage collection. Manageable. (Introduced in 1.4.0.)
-XX:-PrintGCTimeStamps Print timestamps at garbage collection. Manageable (Introduced in 1.4.0.)
-XX:-PrintTenuringDistribution Print tenuring age information.
-XX:-PrintAdaptiveSizePolicy Enables printing of information about adaptive generation sizing.
-XX:-TraceClassLoading Trace loading of classes.
-XX:-TraceClassLoadingPreorder Trace all classes loaded in order referenced (not loaded). (Introduced in 1.4.2.)
-XX:-TraceClassResolution Trace constant pool resolutions. (Introduced in 1.4.2.)
-XX:-TraceClassUnloading Trace unloading of classes.
-XX:-TraceLoaderConstraints Trace recording of loader constraints. (Introduced in 6.)
-Xloggc:<filename> Log GC verbose output to specified file. The verbose output is controlled by the normal verbose GC flags.
-XX:-UseGCLogFileRotation Enabled GC log rotation, requires -Xloggc.
-XX:NumberOfGClogFiles=1 Set the number of files to use when rotating logs, must be >= 1. The rotated log files will use the following naming scheme, <filename>.0, <filename>.1, ..., <filename>.n-1.
-XX:GCLogFileSize=8K The size of the log file at which point the log will be rotated, must be >= 8K.
posted @ 2018-09-05 11:03  随机排序  阅读(483)  评论(0)    收藏  举报