1

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.

Jiruffe
  • 47
  • 5
  • sorry but i mean jar from network not local files – Jiruffe Dec 19 '18 at 09:21
  • 1
    I think you have only two options : 1. JNLP (Java Network Launch Protocol) files 2. download jar in local files, set classpath then execute it manually with your program – Omid P Dec 19 '18 at 09:50
  • Does this answer your question? [remote jars in the classpath](https://stackoverflow.com/questions/14247716/remote-jars-in-the-classpath) – xerx593 Nov 16 '22 at 14:06

1 Answers1

0

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

Jabongg
  • 2,099
  • 2
  • 15
  • 32
  • possible duplicate of : https://stackoverflow.com/questions/9395207/how-to-include-jar-files-with-java-file-and-compile-in-command-prompt – Jabongg Dec 19 '18 at 09:13