Get ClassPath from RuntimeMXBean in Java

Java 8Object Oriented ProgrammingProgramming

RuntimeMXBean in the management interface for the runtime system of the Java virtual machine.

RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean();

To get the class path, use the getClassPath() method −

runtimeMX.getClassPath()

The following is an example −

Example

 Live Demo

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());
   }
}

Output

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
raja
Published on 26-Dec-2018 11:23:30
Advertisements