Java JMX RuntimeMXBean
JMX Java About 2,272 words功能
RuntimeMXBean
可以获取:
Pid
:Java
运行的进程号StartTime
:Java
启动的时间Uptime
:Java
当前运行了多久时间Name
: 获取当前Java
运行在的主机名InputArguments
: 获取Java
启动时的命令行参数VmXXX
: 获取Java
虚拟机相关的信息
代码
public class RuntimeMXBeanTest {
public static void main(String[] args) {
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
System.out.println("pid#" + runtimeMXBean.getPid());
System.out.println("startTime#" + runtimeMXBean.getStartTime());
System.out.println("uptime#" + runtimeMXBean.getUptime());
System.out.println("name#" + runtimeMXBean.getName());
System.out.println("classPath#" + runtimeMXBean.getClassPath());
System.out.println("libraryPath#" + runtimeMXBean.getLibraryPath());
System.out.println("inputArguments#" + runtimeMXBean.getInputArguments());
System.out.println("managementSpecVersion#" + runtimeMXBean.getManagementSpecVersion());
System.out.println("vmName#" + runtimeMXBean.getVmName());
System.out.println("vmVendor#" + runtimeMXBean.getVmVendor());
System.out.println("vmVersion#" + runtimeMXBean.getVmVersion());
System.out.println("specName#" + runtimeMXBean.getSpecName());
System.out.println("specVersion#" + runtimeMXBean.getSpecVersion());
System.out.println("specVendor#" + runtimeMXBean.getSpecVendor());
if (runtimeMXBean.isBootClassPathSupported()) {
System.out.println("bootClassPath#" + runtimeMXBean.getBootClassPath());
} else {
System.out.println("bootClassPath not support");
}
}
}
输出
pid#61456
startTime#1704020195620
uptime#91
name#61456@fendoudebb
classPath#/Users/fendoudebb/github/quick-learn/java/target/production/quick-learn
libraryPath#/Users/fendoudebb/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
inputArguments#[-javaagent:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar=62957:/Applications/IntelliJ IDEA.app/Contents/bin, -Dfile.encoding=UTF-8]
managementSpecVersion#2.0
vmName#OpenJDK 64-Bit Server VM
vmVendor#Eclipse Adoptium
vmVersion#11.0.17+8
specName#Java Virtual Machine Specification
specVersion#11
specVendor#Oracle Corporation
bootClassPath not support
Views: 591 · Posted: 2023-12-31
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...