Skip to content

Instantly share code, notes, and snippets.

@dyerrington
Created January 21, 2016 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dyerrington/ce7b6be5530104fb13a0 to your computer and use it in GitHub Desktop.
Save dyerrington/ce7b6be5530104fb13a0 to your computer and use it in GitHub Desktop.
Easily print classpath and jar files of loaded classes in scala.
def urlses(cl: ClassLoader): Array[java.net.URL] = cl match {
case null => Array()
case u: java.net.URLClassLoader => u.getURLs() ++ urlses(cl.getParent)
case _ => urlses(cl.getParent)
}
val urls = urlses(getClass.getClassLoader)
urls.filterNot(_.toString.contains("ivy")).foreach(println)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment