Ch10 Modules Flashcards

1
Q

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.

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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.

A

java –module-path test –module book.module/com.sybex.OCP

–module-path can be replaced by -p and –module can be replaced by -m

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Package everything under the ‘test’ directory to the mods directory under the name zoo.animal.feeding

A

jar -cvf mods/zoo.animal.feeding.jar -C test/ .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What command can we use to find out what the module structure is of a jar file?

A

java -p {module-path here} -d {module here}

or

java -p {module-path here} –describe-module {module here}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What command can we use to list available modules?

A

java –list-modules
/
java -p mods –list-modules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What flag can we use to print debugging information when running the modules?

A

–show-module-resolution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What command can we use to get information about dependencies within a module that are actually used (and not just declared)?

A

The jdeps command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Use a command to get information about actual dependencies of the module zoo.staff in the directory mods.

A

jdeps mods/zoo.staff.jar

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Use a command to get a summary of the information about actual dependencies of the module zoo.staff in the directory mods.

A

jdeps -s mods/zoo.staff.jar

or

jdeps -summary mods/zoo.staff.jar

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Name all important JMOD operations

A

create, extract, describe, list, hash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly