github classgraph/classgraph classgraph-4.8.20

latest releases: classgraph-4.8.171, classgraph-4.8.170, classgraph-4.8.169...
5 years ago

Allow manual scanning of only rt.jar (thanks to @jechlin for the request).

This code will locate and scan rt.jar:

String rtJarPath = null;
for (URI uri : new ClassGraph().enableSystemJarsAndModules().getClasspathURIs()) {
    if (uri.getPath().endsWith("/rt.jar")) {
        rtJarPath = uri.getPath();
        break;
    }
}
if (rtJarPath == null) {
    // rt.jar will not be found on JDK 9+ -- you need to scan system modules instead
    throw new RuntimeException("rt.jar not found");
}
try (ScanResult scanResult = new ClassGraph().overrideClasspath(rtJarPath)
        .enableSystemJarsAndModules().enableAllInfo().scan()) {
    System.out.println("Found " + scanResult.getAllClasses().size() + " classes in rt.jar");
}

Don't miss a new classgraph release

NewReleases is sending notifications on new releases.