This example demonstrates how to get the classpath string using the Java program. It is simple that you just need to use the System.getProperty() method with the classpath variable name which will return the classpath string. Lets look at the example.
package javabeat.net.core; /** * This example program prints the classpath value * * @author krishna * */ public class JavaCoreExample { public static void main(String[] args) { // Call System property to get the classpath value String classpathStr = System.getProperty("java.class.path"); System.out.print(classpathStr); } }
Output
/home/krishna/workspace/Java Project/bin:/home/krishna/JARS/itext-5.4.4/itextpdf-5.4.4.jar:/home/krishna/JARS/itext-5.4.4/itext-pdfa-5.4.4.jar:/home/krishna/JARS/itext-5.4.4/itext-xtra-5.4.4.jar
This is the simple example to get the classpath configuration in your system by using the Java code. If you have any questions please write it in the comments section.