Reputation: 37
Right now I'm trying to develop a Java project with pure java (no builtscript). I'm implementing the module concept from Java 9. I'm having a trouble when it comes to run a Java project (main class) with additional jar file (third party library). I have no trouble when compiling but when I try to run the java it couldn't run as expected.
I could compile this project by executing this command (javaFiles.txt contains my java files that wanted to be compiled):
javac --module-path lib -d newout --module-source-path src @javaFiles.txt
But when I try to run the compiled .class file with this command:
java --module-path newout;libs --module com.example.trial/com.example.trial.CreateProduct
I got this error as if it's a wrong command:
$ java --module-path newout;libs --module com.example.trial/com.example.trial.CreateProduct
Usage: java [options] <mainclass> [args...]
(to execute a class) or java [options] -jar <jarfile> [args...]
(to execute a jar file)
...
I'm using ubuntu. Is there any other way to do it?
And also I don't really know the differences between classpath, modulepath and whatsoever. I always try to run this from module path.
I got some references from this link and this link. Those two tells me the command that I've mentioned above.
Thank you!
Upvotes: 2
Views: 2283
Reputation: 44414
The path separator in all non-Windows systems is colon (:
), not semicolon (;
). You need to change this:
java --module-path newout;libs
to this:
java --module-path newout:libs
Unix shells use ;
to separate two consecutive commands. So your original line was actually trying to execute these two commands:
$ java --module-path newout
$ libs --module com.example.trial/com.example.trial.CreateProduct
Upvotes: 4