当前位置:   article > 正文

java获取MX_从Java中的RuntimeMXBean获取引导路径

runtimemxbean

Java虚拟机的运行时系统的管理界面中的RuntimeMXBean。RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean();

要获取启动路径,请使用getBootClassPath()方法-runtimeMX.getBootClassPath()

以下是一个例子-

示例import java.lang.management.ManagementFactory;

import java.lang.management.RuntimeMXBean;

import java.util.Date;

public class Demo {

public static void main(String args[]) throws Exception {

RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean();

System.out.println("Class path = "+runtimeMX.getClassPath());

System.out.println("Boot Class path = "+runtimeMX.getBootClassPath());

}

}

输出结果Class path = /home/cg/root/GNUstep/Library/Libraries/Java:/usr/GNUstep/Local/Library/Libraries/Java:/usr/GNUstep/System/

Library/Libraries/Java::/usr/share/java/mysql-connector-java.jar:.:/var/www/html/lib:/var/www/html/lib/dom4j-

1.6.jar:/var/www/html/lib/guava-18.0.jar:/var/www/html/lib/jackson-all.jar:/var/www/html/lib/jaxen-

1.1.4.jar:/var/www/html/lib/jcommon.jar:/var/www/html/lib/jdom2-

2.0.5.jar:/var/www/html/lib/jfreechart.jar:/var/www/html/lib/junit-4.12.jar:/var/www/html/lib/spymemcached-

2.10.3.jar:/var/www/html/lib/stax-1.2.0.jar:/var/www/html/lib/xstream-1.4.7.jar:/var/www/html/lib/gson-

2.3.1.jar:/var/www/html/lib/hamcrest-core-1.3.jar

Boot Class path = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-

1.b16.fc26.x86_64/jre/lib/resources.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-

1.b16.fc26.x86_64/jre/lib/rt.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-

1.b16.fc26.x86_64/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-

1.b16.fc26.x86_64/jre/lib/jsse.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-

1.b16.fc26.x86_64/jre/lib/jce.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-

1.b16.fc26.x86_64/jre/lib/charsets.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-

1.b16.fc26.x86_64/jre/lib/jfr.jar:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-1.b16.fc26.x86_64/jre/classes

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/372272
推荐阅读
相关标签
  

闽ICP备14008679号