1Z0-819 · Question #152
Which command line runs the main class com.acme.Main from the module com.example?
The correct answer is D. java --module-path example.jar -m com.example/com.acme.Main. Option D is correct because it combines two required elements: the -m flag (or --module) to specify the module, and the module/mainclass format (com.example/com.acme.Main), with the module packaged as example.jar on the module path. A is wrong because it omits the -m flag…
Question
Options
- Ajava --module-path mods com.example/com.acme.Main
- Bjava --module-path mods com.acme.Main
- Cjava --module-path mods -m com.example/com.acme.Main
- Djava --module-path example.jar -m com.example/com.acme.Main
How the community answered
(27 responses)- A4% (1)
- B7% (2)
- C15% (4)
- D74% (20)
Explanation
Option D is correct because it combines two required elements: the -m flag (or --module) to specify the module, and the module/mainclass format (com.example/com.acme.Main), with the module packaged as example.jar on the module path.
- A is wrong because it omits the
-mflag entirely - without it, Java treatscom.example/com.acme.Mainas a class name, which is invalid syntax. - B is wrong for the same reason: no
-mflag, andcom.acme.Mainwithout a module qualifier is just an unqualified class name, which won't resolve correctly in the module system. - C has the correct syntax structure (
-m com.example/com.acme.Main) but usesmods(a directory) as the module path instead of the actual JAR fileexample.jar- the module can't be found if the path doesn't point to where it lives.
Memory tip: Think of -m as "module mode" - you always need it when launching from the module system, and the argument always follows the pattern moduleName/fullyQualifiedMainClass. If you see a command with --module-path but no -m, it's broken.
Topics
Community Discussion
No community discussion yet for this question.