9

I am having the following situation:

Module Address:

module org.abondar.experimental.address {
    exports org.abondar.experimental.address;
}

Module Person:

module org.abondar.experimental.person {
    requires org.abondar.experimental.address;
    exports org.abondar.experimental.person;
}

I am building them using Maven, so every module has it's own target dir with jar file.

I am trying to run module Person which has main class like this

java --module-path Address/target/Address-1.0.jar;Person/target/Person-1.0.jar -m org.abondar.experimental.person/org.abondar.experimental.person.Main

But I am getting permission denied. How do I need to set up module path including several modules?

Omid
  • 5,823
  • 4
  • 41
  • 50
Alex Bondar
  • 1,167
  • 4
  • 18
  • 35

1 Answers1

4

Well trying this on one of my projects with MacOS, I almost ended up with something similar as this -

zsh: permission denied: .../.m2/repository/test/test/1.0.0-SNAPSHOT/test-1.0.0-SNAPSHOT.jar
zsh: permission denied: .../.m2/repository/org/slf4j/slf4j-log4j12/1.7.12/slf4j-log4j12-1.7.12.jar
zsh: permission denied: .../.m2/repository/org/slf4j/slf4j-api/1.7.12/slf4j-api-1.7.12.jar

The reason for that error is that the paths to the JARs are specified as a command to be executed on MacOS instead.

If you consider the module path as a list of directories for MacOS(might be Unix in general) it doesn't match the java tool documentation. Instead what you could seek for is

java --help

which states

--module-path <module path> ... A : separated list of directories, each directory is a directory of modules.

and in that case the command that shall work for you shall be :-

java --module-path Address/target/Address-1.0.jar:Person/target/Person-1.0.jar -m org.abondar.experimental.person/org.abondar.experimental.person.Main
Naman
  • 27,789
  • 26
  • 218
  • 353
  • 2
    I'm interested to know where the "permission denied" is coming from. Is this a script rather than java? On the module path then `java --help` doesn't have enough space in its output to show all the details. Instead see JEP 261 where you'll see that the entries on the module path can be modules or directories of modules. – Alan Bateman Dec 21 '17 at 08:28
  • @AlanBateman At first seems to me as well, like the `--help` output is not completely contained in the output and along with that occurs this permission denied. Would look into this further to find out what exactly is causing the permission denied.(for me atleast) – Naman Dec 21 '17 at 08:46
  • @AlanBateman By *one of my projects with MacOS* I meant I executed a similar command with ***;*** separated path and that is where I got the above-shared error. The path in my command line had those *.m2/repository* directories. Also to add to the details, I get a similar error while I trying something as plain as `../.m2/repository/test/test/1.0.0-SNAPSHOT/test-1.0.0-SNAPSHOT.jar` (yes, no command other than this). maybe the shell is responsible for it. Left a little puzzled myself. – Naman Dec 21 '17 at 11:00
  • 3
    the ; is used to separate commands on OS X (and other Unix/Linux systems). So I suspect you are use the path to the JAR file as a command, that would explains the "permission denied" error. – Alan Bateman Dec 27 '17 at 15:46
  • @AlanBateman Well indeed I am ending up specifying the path as a command and that does explain the error too. Thanks :) – Naman Dec 27 '17 at 15:48