Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List modules in jar file

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?

like image 229
PopKernel Avatar asked Oct 07 '17 03:10

PopKernel


People also ask

Can a jar contain multiple modules?

It is that file that defines a module's name, dependencies, and APIs. So there is a strong connection between JARs and modules: JARs are the containers from which the module system creates modules and (at the moment) each JAR can only contain a single module.

What classes are in jar?

The JAR file contains the TicTacToe class file and the audio and images directory, as expected. The output also shows that the JAR file contains a default manifest file, META-INF/MANIFEST. MF, which was automatically placed in the archive by the JAR tool.


2 Answers

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

jar --file=myjar.jar --describe-module
like image 96
Alan Bateman Avatar answered Oct 30 '22 17:10

Alan Bateman


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.

like image 28
Naman Avatar answered Oct 30 '22 17:10

Naman