Skip to content

Instantly share code, notes, and snippets.

@jessitron
Created January 11, 2014 20:15
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save jessitron/8376139 to your computer and use it in GitHub Desktop.
Save jessitron/8376139 to your computer and use it in GitHub Desktop.
scala: print all URLs on classpath
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)
println(urls.filterNot(_.toString.contains("ivy")).mkString("\n")
@rgorsuch
Copy link

Handy! Thank you. There's a missing paren on the last line. Check out my fork: https://gist.github.com/rgorsuch/b404c658551a6a8aeb35

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