Skip to content

Instantly share code, notes, and snippets.

@prakharjain09
Last active February 28, 2020 14:11
Show Gist options
  • Select an option

  • Save prakharjain09/7b49cfb1c797022f20c7b1266b2ce82b to your computer and use it in GitHub Desktop.

Select an option

Save prakharjain09/7b49cfb1c797022f20c7b1266b2ce82b to your computer and use it in GitHub Desktop.
Get all jars in classpath (Scala)
def list_urls(cl: ClassLoader): Array[java.net.URL] = cl match {
case null => Array()
case u: java.net.URLClassLoader => u.getURLs() ++ list_urls(cl.getParent)
case _ => list_urls(cl.getParent)
}
val urls = list_urls(getClass.getClassLoader).distinct
println(urls.filterNot(_.toString.contains("ivy")).mkString("\n"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment