List modules in jar file
Asked Answered
C

3

27

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?

Carney answered 7/10, 2017 at 3:57 Comment(0)
C
44

The alternative is to use the jar --describe-module (-d for short), e.g.:

jar --file=myjar.jar --describe-module
Chaudfroid answered 7/10, 2017 at 7:52 Comment(0)
D
16

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.

Dilapidate answered 7/10, 2017 at 5:37 Comment(2)
I recommend to use jar --describe-module instead - it's much more precise and contains more relevant information.Lane
This way is handy for checking which modules are built into the runtime image (say as built using jlink/jpackage) with java --list-modules.Greataunt
B
-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.

Barrada answered 7/10, 2017 at 4:11 Comment(4)
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.Carney
Modules? Do you mean external libraries?Barrada
No, modules as in Java 9 modules, aka project Jigsaw…Carney
I’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.Barrada

© 2022 - 2024 — McMap. All rights reserved.