Skip to Content

Get classpath using System class

  1. /*
  2.         Get classpath using System class
  3.         This example shows how to get the classpath using
  4.         System class.
  5. */
  6.  
  7. public class PrintClassPath {
  8.  
  9.         public static void main(String[] args) {
  10.        
  11.                 /*
  12.                  * Get java.class.path system property using
  13.                  * public static String getProperty(String name) method of
  14.                  * System class.
  15.                  */
  16.                  
  17.                  String strClassPath = System.getProperty("java.class.path");
  18.                  
  19.                  System.out.println("Classpath is " + strClassPath);
  20.  
  21.         }
  22. }
  23.  
  24. /*
  25. Output would be system dependent
  26. */