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
5
votes
0 answers

How do I write module-info requires statement from GAV coordinates of a non-modular dependency?

I am converting a legacy java app to a modular one. It is a Gradle project, and the dependencies look like this: dependencies { implementation 'org.jopendocument:jOpenDocument:1.3' implementation 'xom:xom:1.3.2' } In the App class, my…
5
votes
0 answers

SLF4J in 2 dependencies in Java 9

I'm developing an application (https://github.com/stirante/RuneChanger) and a library (https://github.com/stirante/lol-client-java-api) to that application. In library I use Java-WebSocket, which recently added SLF4J API. In application I have…
stirante
  • 118
  • 8
5
votes
0 answers

Error: JavaFX runtime components are missing, and are required to run this application - Analysis

Starting with badass-runtime-example-javafx which works for me, I copied this project and extended it with my own code. I created an image with gradlew runtime. When executing the generated .bat file on Windows, I get "Error: JavaFX runtime…
user250343
  • 1,163
  • 1
  • 15
  • 24
5
votes
2 answers

Intellij Error:(3, 4) java: modules are not supported in -source 8 (use -source 9 or higher to enable modules)

Edit - this is solved - the issue was solved by setting: "Settings -> Build, Execution, Deployment - Java Compiler -> Project Bytecode Version : 9" I'm following the example/tutorial at…
JL_SO
  • 1,742
  • 1
  • 25
  • 38
5
votes
1 answer

How to use launch4j with a Java custom runtime image?

Is it possible to make a bundle/wrapper exe file with Launch4j with a modular java app? The app is modular (jmods), exported with jlink, it doesn't generate any jar, but a custom runtime image (a few folders) with a bat file that runs the command:…
tec
  • 999
  • 3
  • 18
  • 40
5
votes
1 answer

Is it possible to start a Java Runtime Image with prunsrv using jvm mode?

Background: Since Java 9 it is possible to create custom runtime images (JRE+program) using jlink. It is possible to install Java programs as Windows service using prunsrv.exe (part of Apache Commons Daemon). prunsrv can be used in three start…
Gustave
  • 3,359
  • 4
  • 31
  • 64
5
votes
3 answers

Module moduleA not found in module source path , trying to compile

After this question was answered i published java 9 modules tutorials + examples on Github and how to run for future users : I have the below very simple structure: src │ module-info.java │ └───moduleA └───pack1 …
GOXR3PLUS
  • 6,877
  • 9
  • 44
  • 93
5
votes
1 answer

Why open a non-existing package from a Java module?

The JLS 11 "7.7.2. Exported and Opened Packages" says: It is permitted for opens to specify a package which is not declared by a compilation unit associated with the current module. What would be a scenario for this? Why is this needed?
Barat Sahdzijeu
  • 1,683
  • 1
  • 18
  • 29
5
votes
1 answer

Ambiguous call to Module

I am trying to recompile a JAVA8 code in JAVA11. Getting below compilation errors. error: reference to Module is ambiguous private Module module; both interface com.module.Module in com.module and class java.lang.Module in java.lang…
5
votes
1 answer

Any solution to LayerInstantiationException - Package license in both module?

I have three modules named core, common and item and each module is a child module to the Maven project. I'm using ServiceLoader to achieve a service approach and Java 11 with fontawesomefx 11 (lastest). I have not worked with Java's module system,…
treeden
  • 675
  • 1
  • 6
  • 17
5
votes
2 answers

Logback in a Java 9 modular application not working

I have a Maven project with Java 9 and am using modules. Logback seems to support this since version 1.3.0-alpha1 but unfortunately I didn't got it to work. I get the following message from SLF4J: SLF4J: No SLF4J providers were found. SLF4J:…
Itchy
  • 2,263
  • 28
  • 41
5
votes
1 answer

how to generate javadoc for multiple modules

I'm trying to create javadoc (jdk11) for multiple modules in a single document. I tried to do it like this. The file/directory structure is: workspace doc maths src main java …
stegzzz
  • 407
  • 4
  • 9
5
votes
1 answer

How do Java Module directives impact reflection access into a module?

According to https://www.oracle.com/corporate/features/understanding-java-9-modules.html, the Java Module system introduces the following directives: exports, exports ... to uses provides ... with open, opens, opens ... to What (if any) impact…
Gili
  • 86,244
  • 97
  • 390
  • 689
5
votes
2 answers

Java module glossary

What is the difference between all these terms used in the Java module specification? I can't find a definition of these terms that doesn't circularly reference itself. Visible Observable Accessible The spec makes such statements as this, but I…
Doradus
  • 938
  • 1
  • 9
  • 15
5
votes
1 answer

Compile Module that Depends on an External Jar

I worked through a simple example using Project Jigsaw in Java 11.0.1, built using the oracle JDK 11 on Ubuntu 18.04. Following that example, I have created a simple project which compiles to a module, packages the module into a jar, and then uses…
Grumblesaurus
  • 3,021
  • 3
  • 31
  • 61