From the course: Java SE 17 Developer (1Z0-829) Cert Prep

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Module execution

Module execution

- It's time to look at executing a module. When we start a program, we'll need three things: the entry point where the program starts, where to find the modules to support that, and which modules are actually needed. The entry point is specified using the --module or -m shorthand directive. So we need to specify the module name, and then we put a forward slash, and then the fully.qualified.ClassName that contains the main method we want to launch. So for example, --module test.module/my.pkg.MyClass. Modules will be found by looking in the list of directories enumerated in the --module-path, or -p for short, specification. So, this is exactly the same as the compilation phase. We must use the platform specific separator if we need a list of those. And looking ahead, a module specifies the other modules upon which it is dependent. So that's done, of course, using the requires directive. Let's look at a very simple example of this. So here is the MyClass from our previous example, and…

Contents