Is there any way to get list of directories which are included in module-path with use of -p
or --module-path
arguments at runtime similar to how I whold get all classpath directories using System.getProperty("java.class.path")
?
Asked
Active
Viewed 1,316 times
7

Naman
- 27,789
- 26
- 218
- 353

Artem Petrov
- 772
- 4
- 17
-
Why do you need the `modulepath`? What use case do you have? – ZhekaKozlov May 26 '18 at 15:00
-
@ZhekaKozlov Just for debug purposes – Artem Petrov May 26 '18 at 15:21
-
4The system property is `jdk.module.path`, documented in System.getProperties(). For completeness, you may want to look at the value of `jdk.module.upgrade.path`, also documented in System.getProperties(). – Alan Bateman May 26 '18 at 16:04
-
@AlanBateman But why I don't have such systems properties even when `--module-path` was actually used? I am using java.runtime.version=9+181 – Artem Petrov May 27 '18 at 06:32
1 Answers
11
From Javadoc of System.getProperties
:
In addition to the standard system properties,
the system properties may include the following keys:
Key Description of Associated Value
jdk.module.path The application module path
jdk.module.upgrade.path The upgrade module path
jdk.module.main The module name of the initial/main module
jdk.module.main.class The main class name of the initial module
So you should use System.getProperty("jdk.module.path")

ZhekaKozlov
- 36,558
- 20
- 126
- 155
-
2A better way would be [as suggested by Alan](https://stackoverflow.com/questions/50543982/inspect-module-path-value-at-runtime#comment88100258_50543982) – Naman May 26 '18 at 16:18