Skip to content

Instantly share code, notes, and snippets.

@zasadnyy zasadnyy/print class path
Last active Nov 23, 2018

What would you like to do?
Print all files and folders added to java classpath
public static void main(String[] args)
ClassLoader cl = ClassLoader.getSystemClassLoader();
URL[] urls = ((URLClassLoader)cl).getURLs();
for(URL url: urls){
testClasses.doFirst {
println "Test classpath is:- "
sourceSets.test.runtimeClasspath.getFiles().each { file ->
println "file: \"" + file + "\""

This comment has been minimized.

Copy link

Masterxilo commented Nov 23, 2018

//Exception in thread "main" java.lang.ClassCastException: java.base/jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to java.base/
// at ShowClasspath.main(

There is no guarantee that the class loader is a urlclassloader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.