Free Data Structures and Algorithms Course









Subscribe below and get all best seller courses for free !!!










OR



Subscribe for all free courses

How to get Java classpath using RuntimeMXBean and System class in Java ?

Program to demonstrate how to get Java classpath using RuntimeMXBean and System class in Java

package com.hubberspot.example;

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;

public class JavaClassPath {

   public static void main(String[] args) {
  
 // Create RuntimeMXBean object through getRuntimeMXBean()
 // of the ManagementFactory
 RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
 // Call getClassPath() of RuntimeMXBean object to get 
 // java class path
 String classpath = runtime.getClassPath();
 System.out.println("Java Class Path : " + classpath);
  
 // Call getProperty("java.class.path") of System class
 // to get another way of getting java class path
 classpath = System.getProperty("java.class.path");
 System.out.println("Java Class Path : " + classpath);

   }

}




Output of the program :



 
© 2021 Learn Java by Examples Template by Hubberspot