I teach Java programming courses in a college setting. It would make sense to use the latest LTS version (Java 11) in the courses. We teach user interfaces using JavaFX. However, the combination of JavaFX plus the module system creates complications, especially for beginners.
In order to use JavaFX, one must have a module-info.java
file which looks something like this:
module MyProject {
// JavaFX must be able to start the application
exports myPackage to javafx.graphics;
// JavaFX modules that we require
requires javafx.base;
requires javafx.controls;
requires javafx.graphics;
}
Students normally use a single Java project for each course. In each course, they get many examples from me, and will write many more programs themselves. Each of these examples and exercises has it's own main class, and they are organized into many different packages.
The problem is that first exports
statement: As far as I am aware, each statement applies only to a single package, no wildcards are possible, and sub-packages are not included. Hence, if we have a Java project with 50 different packages, module-info.java
will contain fifty exports
statements. This is a mess.
Maybe this seems minor, but it is yet another hurdle for people just learning to program. Have I overlooked some way to generalize exports
to cover multiple packages? Alternatively, does anyone have a good suggestion on ways to simplify this for my students?