I have a code that currently gets all jars from the classpath:
final URLClassLoader loader = (URLClassLoader) MyClass.class.getClassLoader();
URL[] urls = loader.getURLs();
This works fine with Java 8, but not in Java 11.
In Java 11 we have to change the mechanism to use System.getProperty("java.class.path")
This works ok, but breaks when using mvn exec:java
because the classloader in that plugin is plexus
.
The only jar in the classpath is /usr/local/Cellar/maven/3.6.0/libexec/boot/plexus-classworlds-2.5.2.jar
.
Is there a way to get all the jars for this maven plugin or classloader?