Dynamically adding to the classpath in a post Java 9 world. Help?

I actually struggled with the same issue and ultimately managed to make it work. You actually just need to add DynamicClassLoader and assign it to clojure.lang.Compiler/LOADER
See for example here.
Took me quite a long time before realizing that things that do not work in REPL might work in standalone mode (I was kinda expecting it to be only the other way around).
So basically though my solution does not work in REPL (probably due to new classloaders being created and bound repeatedly), when run normally (via java -jar …) it actually works - I tested it on Java 9 - 11 and it works even when using the Pomegranate 1.1.0 with Dynapath 1.0.0. (I use them e.g. here ).
When I want to use/test in REPL I simply have a separate lein profile that uses Java 8 and Pomegranate 1.0.0 and Dynapath 0.4.0

1 Like