Pin It

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 :



Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Related Posts Plugin for WordPress, Blogger...

Post your related queries below ...

comments powered by Disqus
Powered by Blogger.
 
© 2012 Learn Java by Examples Template by Hubber Spot