4

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?

Brad Richards
  • 1,233
  • 3
  • 13
  • 23
  • you might want to change the title of the question to better reflect the question content. in the education context, it's better to use the latest available version (so that by the time the students graduate, the versions will still be relevant). – Angel Koh Jul 16 '19 at 08:25
  • Ok, I changed the title to reflect the fact that this is mainly about the Java module system. – Brad Richards Jul 16 '19 at 08:27

1 Answers1

0

Not sure if this is helpful but I started a project of modules in Github. Since your question wasn't answered I'll ask if you found good ways to do this.

My Setting is in Github. Pure Java, with a GitHub action to helps to create the Jars.

https://github.com/disparter/java-snippets

Since I use only one repository, it is easy to share even with many modules. I usually use Discord to discuss and some relevant content I put in a dev notes file but it is in Portuguese.

In my case, I do 2 things.

  1. Create a simple snippet to demonstrate some arguments.
  2. Create a simple module to be able to demonstrate if any a good Object Orientation practice.

OBS

Think in java modules for small pieces. If you want to handle bigger projects is nice to use Gradle or Maven for those. It is interesting in an educational way when dependency problems happen. If you think there are too many modules to import, you can create a module that can be used as a Layer to help import common things.