Here you can find the source of getClasspathString()
private static String getClasspathString()
//package com.java2s; //License from project: Open Source License import java.net.URL; import java.net.URLClassLoader; import java.util.Arrays; import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { private static String getClasspathString() { ClassLoader cl = Optional.ofNullable(Thread.currentThread().getContextClassLoader()) .orElse(ClassLoader.getSystemClassLoader()); while (!URLClassLoader.class.isInstance(cl)) { cl = cl.getParent();/*w ww. java 2 s. c o m*/ if (cl == null) return "Classpath is empty"; } return " " + Stream.of(cl).map(URLClassLoader.class::cast).flatMap(c -> Arrays.stream(c.getURLs())) .map(URL::getFile).collect(Collectors.joining("\n ")) + "\n"; } }