In certain scenario, you may need to load some classes which are not in your classpath. Java Example Assume folder “c:\\other_classes\\” is not in your project classpath, here’s an example to show how to load a Java class from this folder. The code and comments are self-explanatory. import java.io.File; import java.net.URL; import java.net.URLClassLoader; import java.security.CodeSource; […]

Read more How to load classes which are not in your classpath

Java’s “SystemClassLoader” can use to pint out the current project classpath , indirectly display the library dependency as well. Example package com.mkyong.io; import java.net.URL; import java.net.URLClassLoader; public class App{ public static void main (String args[]) { ClassLoader cl = ClassLoader.getSystemClassLoader(); URL[] urls = ((URLClassLoader)cl).getURLs(); for(URL url: urls){ System.out.println(url.getFile()); } } } Output /E:/workspace/HibernateExample/target/test-classes/ /E:/workspace/HibernateExample/target/classes/ /D:/maven/repo/antlr/antlr/2.7.7/antlr-2.7.7.jar […]

Read more How to print out the current project classpath