I've created what I'm pretty sure is a modular jar file. But if possible, I'd like to double check. Given a jar file, is there a way to determine what modules the compiler would find within it?
Asked
Active
Viewed 8,232 times
27
3 Answers
43
The alternative is to use the jar --describe-module
(-d
for short), e.g.:
jar --file=myjar.jar --describe-module

Alan Bateman
- 5,283
- 1
- 20
- 25
15
You can list the modules within the jar using the following java
tool command:-
java -p yourModular.jar --list-modules
Edit: You shall preferably make use of the jar
command lin as suggested in @Alan's answer.

Naman
- 27,789
- 26
- 218
- 353
-
4I recommend to [use `jar --describe-module`](https://stackoverflow.com/a/46617956/2525313) instead - it's much more precise and contains more relevant information. – Nicolai Parlog Oct 07 '17 at 14:11
-
This way is handy for checking which modules are built into the runtime image (say as built using jlink/jpackage) with `java --list-modules`. – DuncG May 21 '23 at 10:39
-4
To extract the contents of a JAR file to see what’s inside, change the extension of the JAR from .jar
to .zip
. Then you can extract the files with whatever zip extraction tool you choose.

Steampunkery
- 3,839
- 2
- 19
- 28
-
I know how to extract the jar. I was wondering if there was an easier way to determine what modules it contains than poring over the source files. – PopKernel Oct 07 '17 at 04:13
-
-
2
-
1I’m sorry, I’ve never worked in Java 9. I misunderstood the question. I don’t know if any way to do what you are asking. – Steampunkery Oct 07 '17 at 04:20