Skip to content

Instantly share code, notes, and snippets.

@zasadnyy
Last active August 2, 2021 08:25
Show Gist options
  • Save zasadnyy/126ae19718b547ee3b9e to your computer and use it in GitHub Desktop.
Save zasadnyy/126ae19718b547ee3b9e to your computer and use it in GitHub Desktop.
Print all files and folders added to java classpath
// JAVA
public static void main(String[] args)
{
ClassLoader cl = ClassLoader.getSystemClassLoader();
URL[] urls = ((URLClassLoader)cl).getURLs();
for(URL url: urls){
System.out.println(url.getFile());
}
}
// GRADLE
testClasses.doFirst {
println "Test classpath is:- "
sourceSets.test.runtimeClasspath.getFiles().each { file ->
println "file: \"" + file + "\""
}
}
@benjamin-asdf
Copy link

Can somebody post a snipped that works for AppClassLoader or for any class loader? I am a java novice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment