Ng Sharma
Ng Sharma

Reputation: 2192

jdeps command does not work with -p attribute

When I execute this command:

jdeps  --module-path out --module test

it's fine and it prints all the information. But when I replace --module-path with -p, it throws an exception:

jdeps -p out --module test
Exception in thread "main" java.lang.module.FindException: Module test not found

But according to java we can replace --module-path with -p:

--module-path to -p

So why does it throw the exception?

Upvotes: 1

Views: 227

Answers (1)

Scratte
Scratte

Reputation: 3166

While the options are generally consistent for multiple different programs, it's not the case with the -p option. The Oracle documentation for java says:

--module-path modulepath... or -p modulepath
A semicolon (;) separated list of directories in which each directory is a directory of modules.

But for jdeps, it's:

-p pkg name, -package pkg name, or --package pkg name
Finds dependencies matching the specified package name. You can specify this option multiple times for different packages.

Example of use

This example is based on a module named msg.service.app. It contains only has one package msg.application:

Getting the information about the module without using -p:

..snip..>jdeps --module-path target --module msg.service.app
msg.service.app
 [file:///C:/..snip../target/msg.service.app/]
   requires mandated java.base (@11.0.3)
   requires msg.service.api
msg.service.app -> java.base
msg.service.app -> msg.service.api
   msg.application            -> java.lang                  java.base
   msg.application            -> java.util                  java.base
   msg.application            -> msg.service                msg.service.api

..snip..>

Getting the information about what depends on the package msg.service:

..snip..>jdeps --module-path target -p msg.service --module msg.service.app
msg.service.app
 [file:///C:/..snip../target/msg.service.app/]
   requires mandated java.base (@11.0.3)
   requires msg.service.api
msg.service.app -> msg.service.api
   msg.application            -> msg.service                msg.service.api

..snip..>

Example where it's used on java.base to find out what depends on the sun.util.spi package:

..snip..>jdeps --module java.base -p sun.util.spi
java.base
 [jrt:/java.base]
java.base -> java.base
   java.util                  -> sun.util.spi               java.base
   sun.util.locale.provider   -> sun.util.spi               java.base

..snip..>

Upvotes: 1

Related Questions