How can I get current value of CLASSPATH
in Groovy?
Select Start -> Control Panel -> System -> Advanced -> Environment Variables -> System Variables -> CLASSPATH. If the Classpath variable exists, prepend .;C:\introcs to the beginning of the CLASSPATH varible. If the CLASSPATH variable does not exist, select New.
Classpath in Java is the path to the directory or list of the directory which is used by ClassLoaders to find and load classes in the Java program. Classpath can be specified using CLASSPATH environment variable which is case insensitive, -cp or -classpath command-line option or Class-Path attribute in manifest.
Shameless stolen from http://blog.blindgaenger.net/print_groovys_classpath_for_debugging.html This code will go up the classloader tree and printout each classloader and the associated classpath.
def printClassPath(classLoader) {
println "$classLoader"
classLoader.getURLs().each {url->
println "- ${url.toString()}"
}
if (classLoader.parent) {
printClassPath(classLoader.parent)
}
}
printClassPath this.class.classLoader
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With