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
8
votes
2 answers

Compilation failure: module not found: org.apache.logging.log4j

I have simple application written in Java 11. mvn clean verify (maven 3.6.0) executes with error: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project parser: Compilation…
uli
  • 671
  • 6
  • 15
8
votes
2 answers

Java 9 HttpClient java.lang.NoClassDefFoundError: jdk/incubator/http/HttpClient

I am trying to use the HttpClient from incubator in Java 9 maven project. I am not getting any Compilation issue. The project builds successfully. But when I try to run the Main class, it gives me the following exception: Exception in thread "main"…
parth karia
  • 230
  • 2
  • 7
8
votes
2 answers

Limit modules added by javapackager

I am trying to reduce the size of my application by limiting the modules that it includes. I already did this for my runtime using jlink. However, when I run javapackager using the --add-modules and --limit-modules options with a comma-separated…
GabeV
  • 859
  • 8
  • 21
8
votes
1 answer

Create Module in JShell in Java 9

Just exploring new release of Java, its new module system, and playing with jshell as well. Probably my question doesn't have too much sense, but I am just curious. So I came up with the question: Is there any way to create a module in jshell? Or…
Sergei Sirik
  • 1,249
  • 1
  • 13
  • 28
8
votes
1 answer

Illegal reflective access in an applet with Jaxb and JDK 9

I have a Java applet which provides a GUI to invoke a web service. It uses Jaxb to parse the XML data and unmarshall it into objects. It runs correctly with Java 1.5 to 1.8. With Java 9, not so much. I use a container HTML to launch it in Internet…
AJPerez
  • 3,435
  • 10
  • 61
  • 91
8
votes
2 answers

Creating custom runtime image dedicated for specific modular application

Let's say I'm developing a modular application that consists of 2 modules: com.spacey.explorer that depends on com.spacey.rocket module. I have their modular JAR files in some bin directory. And I want to prepare lightweight JRE to run it. So…
malloc4k
  • 1,742
  • 3
  • 22
  • 22
8
votes
1 answer

Java 9 modules and classpath hell: conflicting class names

It is said that java 9 modules will solve classpath hell. However, I am thinking about the following situation: Module A uses modules B and C. Both modules will export a class with same name and package. How will the classloading issue be solved…
Roxana
  • 1,569
  • 3
  • 24
  • 41
8
votes
1 answer

Java 9 Jigsaw support for javaagent

Is there any plan in Java 9 (specifically Jigsaw) to support the special requirements of Java monitoring agents? Typically, monitoring agents require the ability to access class, packages, and modules that are not available by default to original…
BradW
  • 81
  • 1
8
votes
2 answers

Java 9 overlapping non-exported packages

Various resources (infoq, jigsaw-dev, osdir) indicate that having the same package in different java modules will lead to a LayerInstantiationException, even when the packages are internal to the module (non-exported). This seems to be the exact…
Bax
  • 4,260
  • 5
  • 43
  • 65
7
votes
2 answers

Why does JPMS allow annotation types as services

In introducing JPMS services, section 7.7.4 of the Java Language Specification notes that "The service type must be a class type, an interface type, or an annotation type." I'm struggling to see the point of permitting an annotation. My…
Toby Eggitt
  • 1,806
  • 19
  • 24
7
votes
4 answers

springframework ldap core propblem with java modules

Had this kind of problem with main java module. rg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapContextSource' defined in class path resource…
rauno lõhmus
  • 75
  • 1
  • 4
7
votes
3 answers

Gradle build - add module path

My question: How do I set a module path for gradle build? I've become comfortable working with Java modules from the command line. I do a frequent exercise in Powershell which results in these source files. └───src ├───appMod │ │ …
Jack J
  • 1,514
  • 3
  • 20
  • 28
7
votes
1 answer

Java module system: 'provides with' generic interface

I'm experimenting with the Java module system. I'm trying to use the ServiceLoader for generic interfaces. It works but I've got warnings in the module-info. Here is my minimal code module testProvideWith { provides ServiceGeneric with SString; …
Marco Servetto
  • 684
  • 1
  • 5
  • 14
7
votes
2 answers

idea: too many module declarations found

I want to create hello world java 9 application and start it in intellij idea. Now I have following structure: content of inner module-info.java: module my.module.Second { requires my.module.First; } content of outer module-info.java: module…
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
7
votes
2 answers

Javadoc comments in module-info

The Java 9 modules feature adds (higher-level) module-info files in addition to the package-info files that existed previously. Can module-info.java (source-code) files include marked-up comments that the JavaDoc tool will extract and present…
Raedwald
  • 46,613
  • 43
  • 151
  • 237