1

I need to print the current classpath in a Kotlin program. What alternatives are?

My application is package in a jar file and I using Kotlin 1.3.61 and OpenJDK 8.

JuanMoreno
  • 2,498
  • 1
  • 25
  • 34

1 Answers1

4

We can use:

(java.net.URLClassLoader.getSystemClassLoader() as java.net.URLClassLoader).getURLs().forEach({println(it.getFile())})

Or

println(System.getProperty("java.class.path"))

But there behave with differences, more details here: What's the difference between System.getProperty("java.class.path") and getClassLoader.getURLs()?

JuanMoreno
  • 2,498
  • 1
  • 25
  • 34