Ch10 Modules Flashcards
Given a module ‘zoo.animal.feeding’ with a file Task.java, in the root directory ‘test’ and a directory ‘mods’ containing custom module files.
Compile the code.
javac -p mods test/zoo/animal/feeding/Task.java test/module-info.java
or
javac –module-path mods test/zoo/animal/feeding/Task.java test/module-info.java
Suppose there is a module named book.module which was compiled in the directory ‘test’. Inside that module is a package named com.sybex, which has a class named OCP with a main() method.
Using the above information, run the module.
java –module-path test –module book.module/com.sybex.OCP
–module-path can be replaced by -p and –module can be replaced by -m
Package everything under the ‘test’ directory to the mods directory under the name zoo.animal.feeding
jar -cvf mods/zoo.animal.feeding.jar -C test/ .
What command can we use to find out what the module structure is of a jar file?
java -p {module-path here} -d {module here}
or
java -p {module-path here} –describe-module {module here}
What command can we use to list available modules?
java –list-modules
/
java -p mods –list-modules
What flag can we use to print debugging information when running the modules?
–show-module-resolution
What command can we use to get information about dependencies within a module that are actually used (and not just declared)?
The jdeps command
Use a command to get information about actual dependencies of the module zoo.staff in the directory mods.
jdeps mods/zoo.staff.jar
Use a command to get a summary of the information about actual dependencies of the module zoo.staff in the directory mods.
jdeps -s mods/zoo.staff.jar
or
jdeps -summary mods/zoo.staff.jar
Name all important JMOD operations
create, extract, describe, list, hash