When working with Java modules, developers often encounter two command-line options that serve the same purpose: -m (shorthand) and --module (full). While both specify the main module to launch, there is a subtle difference in how the module path is provided. Understanding this nuance helps you write cleaner and more consistent commands.
The
-moption is a shortcut for--module, but the syntax for passing the module path may vary slightly. Both are equally valid.
For example, to run a module named com.example with the main class Main, you can use:
java -m com.example/com.example.Mainjava --module com.example/com.example.Main
The choice between short and full names often comes down to readability and team conventions. Use whichever makes your build scripts clearer.