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
6
votes
1 answer

Flyway can't access resources during testing after adding `module-info.java`

After upgrading to Java 10 (from 8), I managed to get everything working, but after adding module-info.java, one of the problems I'm having is that Flyway can't access the SQL files when running the tests from the command line. Starting the app or…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
6
votes
1 answer

module has been deprecated and marked for removal

I've added requires transitive java.activation to my module-info.java, but java-10 is giving me a compiler warning module-info.java: module java.activation has been deprecated and marked for removal, despite my having added a dependency on…
Chris Hubick
  • 95
  • 2
  • 4
6
votes
1 answer

signed modular JAR with crypto provider cannot be linked into run-time image

I'm trying to use the jlink tool in order to build a java executable. I'm using it in the following way: jlink.exe --module-path --add-modules --output dist --launcher launch=org.demo/org.demo.Main --strip-debug…
6
votes
2 answers

Java 10: Replacement for java.xml.ws conflict

I have to use java.xml.ws* components in my project but because it's deprecated and will be removed soon I want to use replacement for these components. So I added this dependency to my project's pom file:
nllsdfx
  • 900
  • 14
  • 30
6
votes
2 answers

How to get a Java 9 ModuleReference for an unnamed module

Update: I answered my own question here: Scanning classpath/modulepath in runtime in Java 9 -- [Old question -- obsolete:] What is the correct way to get a ModuleReference given only a Module object in Java 9? Consider these two methods of referring…
Luke Hutchison
  • 8,186
  • 2
  • 45
  • 40
6
votes
0 answers

Java 9: java.lang.ClassNotFoundException: java.sql.SQLException in Spring Boot application

I have built a Spring Boot application with Java 9 ... sourceCompatibility = 9 targetCompatibility = 9 ... and started it with: java --module-path lib -m my.app. ... Caused by: java.lang.NoClassDefFoundError: java/sql/SQLException …
zncoder
  • 61
  • 1
  • 3
6
votes
0 answers

Java 9 service provider and Groovy Extension Modules

In a java 9 project, I'd like to require vertx.web, which is the automatic name given for module io.vertx:vertx-web:3.4.2. Only, at runtime, I get the following error. Error occurred during initialization of boot…
thebignet
  • 128
  • 5
6
votes
3 answers

Any plans for Java 9 Jigsaw (module) of Spring projects?

Java 9 is scheduled to be released soon (July 27). Are there any plans to release a Java 9 compliant version of Spring projects that will be modular (Java 9 project Jigsaw)?
6
votes
1 answer

With Java 9 Modules, will multiple modules be able to export the same package?

I'm trying to use best practices that fit with Java 9 module system so that I have less work to do to get the benefits (and our system right now could really benefit from some modularity). Is it permissible under the current standard for module A to…
Kevin Peterson
  • 7,189
  • 5
  • 36
  • 43
5
votes
0 answers

How to calculate list of needed java modules with jdeps?

I'm basically working with a tomcat webapp that has a complex structure, with many jars and classes at several locations and I want to generate a JRE with jlink and its --add-modules option in order to reduce the weight and attack surface of the…
Simon Campano
  • 87
  • 3
  • 11
5
votes
0 answers

how to deal with reads package javax.activation from both jakarta.activation and java.activation

When trying to run one of the modules, I see many messages of this error. For example: java: module org.apache.commons.compress reads package javax.activation from both jakarta.activation and java.activation What should I do?
IsaacLevon
  • 2,260
  • 4
  • 41
  • 83
5
votes
1 answer

What does a module.a binds module.b mean during the resolution?

While performing a proof of concept for a problem - JPMS ServiceLoader does not work for me as expected. I reached a state to understand the difference in how the two modules were resolved when providing a jar versus target classes to the module…
Naman
  • 27,789
  • 26
  • 218
  • 353
5
votes
1 answer

Can not use JNA: com.sun.jna.Library is not accessible

I am trying to use JNA, because I want to work with a .dll that was written in c++ and the rest of my code is in Java. However, if I try to import the JNA classes Eclipse claims "The type com.sun.jna.Library is not accessible". My IDE seems to see…
vicki-tesch
  • 51
  • 1
  • 4
5
votes
1 answer

How to resolve incubator module jdk.incubator.vector when running Java application

I am attempting to test the new Vector API introduced as an incubator module in JDK 16. For this, I have the following class: import jdk.incubator.vector.FloatVector; import jdk.incubator.vector.VectorSpecies; public class Main { static final…
Regan Koopmans
  • 451
  • 6
  • 16
5
votes
1 answer

xjc and java 11: How to enable episode plugin?

I'm using the command-line xjc from the jaxb-ri 2.3.3 maven artifact(https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-ri/2.3.3/jaxb-ri-2.3.3.zip). It seems that the episode plugin cannot be loaded (more precisely it isn't found at all by the…
MRalwasser
  • 15,605
  • 15
  • 101
  • 147