I'm using JavaCompiler to compile .java code.
It works for me while running the class compiled using URLClassLoader to load remote jars.
But not work while compiling.
Tried to use options like
options.addAll(Arrays.asList("-classpath", "https://example.com/example.jar"));
Also tried to use customized JavaFileManager with URLClassLoader.
None of them works.
try below commands, and replace the .jar file with your external .jar file... into the command prompt or terminal.
$ javac -cp ".:./jars/common.jar" helloworld.java $ java -cp ".:./jars/common.jar" helloworld