Questions tagged [java-module]

Refers to the module as defined by the Java Platform Module System in Java 9+.

A module in the Java Platform Module System is a named, self-describing collection of code and data. Its code is organized as a set of packages containing types, i.e., Java classes and interfaces; its data includes resources and other kinds of static information. The only module known specifically to the module system, in any case, is the base module, which is named java.base.

A module is described using a , which itself is a new construct added in to provide a module definition.

Module names, like package names, must not conflict. The recommended way to name a module is to use the reverse-domain-name pattern that has long been recommended for naming packages. The name of a module will, therefore, often be a prefix of the names of its exported packages, but this relationship is not mandatory.

Module declarations are part of the Java programming language, rather than a language or notation of their own, for several reasons. One of the most important is that module information must be available at both compile time and run time in order to achieve fidelity across phases, i.e., to ensure that the module system works in the same way at both compile time and run time. This, in turn, allows many kinds of errors to be prevented or, at least, reported earlier—at compile time—when they are easier to diagnose and repair.

The Java SE 9 Platform Specification uses the module system to divide the platform into a set of modules. An implementation of the Java SE 9 Platform might contain all of the platform modules or, possibly, just some of them.


A java.lang.Module represents a run-time module, either named or unnamed.

Named modules have a name and are constructed by the Java Virtual Machine when a graph of modules is defined to the Java virtual machine to create a module layer.

An unnamed module does not have a name. There is an unnamed module for each ClassLoader, obtained by invoking its getUnnamedModule method. All types that are not in a named module are members of their defining class loader's unnamed module.

The package names that are parameters or returned by methods defined in this class are the fully-qualified names of the packages as defined in section 6.5.3 of The Java™ Language Specification, for example, java.lang.

727 questions
9
votes
1 answer

java.lang.NoSuchMethodError when using Java 9 modules (JPMS)

I am trying to combine JavaFX, Spring Boot and VLCJ using JPMS modules. Without Spring Boot, things work fine with this in my module-info.java file: module myapplication.module { requires javafx.controls; requires javafx.fxml; requires…
Wim Deblauwe
  • 25,113
  • 20
  • 133
  • 211
9
votes
1 answer

Eclipse cannot find module even the module path is explicitly provided

I have created a module com.company.ep that is located in the source folder com.company.ep. (Yes, I have removed src from the build path and deleted it!) Inside the source folder, I have a couple of packages as the following: com.company.ep <---…
vesontio
  • 381
  • 1
  • 7
  • 19
9
votes
0 answers

Is it safe to grant untrusted code "suppressAccessChecks" when -illegal-access=deny is set?

Without illegal access (--illegal-access=deny) and denying access to jdk.unsupported (done using accessClassInPackage checks), it looks like the ReflectPermission "suppressAccessChecks" would not any longer lead to a full sandbox escape. Is that…
Johannes Kuhn
  • 14,778
  • 4
  • 49
  • 73
9
votes
1 answer

What's the correct to make FXML members in Java 9 or 10?

After upgrading to Java 10 (from 8), I'm getting these errors: InaccessibleObjectException: Unable to make field private javafx.scene.control.Button tech.flexpoint.dashman.controllers.configurator.RegistrationController.registerButton accessible:…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
9
votes
1 answer

How to get boot class path in JDK 9 or later

I have a classloader application that reads the system property sun.boot.class.path But I've found in the JDK 9's release note that this property has been removed. System.getProperty("sun.boot.class.path"); // In JDK 9/10 this returns null But I…
Gayan Weerakutti
  • 11,904
  • 2
  • 71
  • 68
9
votes
1 answer

The jdk.incubator.httpclient module not found in Java11

Using the early access build for JDK/11 to compile an existing code based on Java-9 which was using a VM argument --add-modules jdk.incubator.httpclient to resolve the HTTP/2 client incubator module now ends up with a compilation error Module…
Naman
  • 27,789
  • 26
  • 218
  • 353
9
votes
1 answer

Java Beans Introspector requires desktop module

I'm investigating using Jigsaw to reduce the footprint of a microservice. One of the last dependencies I had to find was java.beans.Introspector. Imagine my surprise when I discovered I needed to bring in the whole module java.desktop which…
Simbosan
  • 244
  • 2
  • 11
9
votes
2 answers

Java 9 error: not in a module on the module source path

Project structure I have a project written in Java 8 and I want to update it to Java 9. So I separated the classes into 2 separate modules. Modules: org.ggp.base with module-info.java in the directory org.ggp.base/src/main/java. Its build was…
banan3'14
  • 3,810
  • 3
  • 24
  • 47
9
votes
3 answers

Best approach to dynamically load modules (classes) in Java

I'm currently writing an application that requires to operate on different type of devices. My approach would be to make a "modular" application that can dynamically load different classes according to the device they need to operate on. To make the…
Mastarius
  • 305
  • 3
  • 13
9
votes
2 answers

creating module-info for automatic modules with jdeps in java 9

I have 3 jar of jackson library jackson-core-2.8.10.jar jackson-annotations-2.8.0.jar jackson-databind-2.8.10.jar I created module-info.java for both core and annotation successfully and converted them to Named maodule using jdeps. for databind ,…
optional
  • 3,260
  • 5
  • 26
  • 47
9
votes
0 answers

Java 9 split package errors in Spring Boot

I get tons of "split package" errors, when I introduce java 9 modules in my SpringBoot code. They are everywhere, eg.: Error:java: the unnamed module reads package org.bson.types from both bson and mongodb.driver Error:java: the unnamed module reads…
9
votes
1 answer

Module is not in dependencies Intellij IDEA 2017.2.5 Java 9

I just tested my java 9 module understanding in command line. Then I moved to Intellij IDEA 2017.2.5 to test it. There I am facing the error module is not in dependencies Don't know why intellij is showing the error. I just write required statements…
8
votes
1 answer

Patch Java 9 module with test-code to work with reflections

How do I add my tests to my production code at test-runtime so that both are in the same Java 9 module and can access each other using reflections? I have tried so far: Remove the Java 9 modularity (actually the module-info.java) → it worked…
Itchy
  • 2,263
  • 28
  • 41
8
votes
1 answer

Java NIO can't read files from JRT image

When we create Java runtime by jlink it takes all java classes/resources and places them into JRT image file: lib/modules. Here is basic Maven project resources structure I use: src main resources dict xkcd_en I'm just trying to…
Evan
  • 649
  • 1
  • 9
  • 22
8
votes
2 answers

Modules not found that are required in module-info.java

All the required modules I've declared in module-info.java are not being found when I run gradle: /Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:10: error: module not found: com.jfoenix requires…
doctopus
  • 5,349
  • 8
  • 53
  • 105