Questions tagged [module-info]

Used for module-info.class related queries used for module declaration in Java since its Java 9 release. This would mostly be coupled with java-9 or above tag.

The State of the Module System defines module declarations as:

A module’s self-description is expressed in its module declaration, a new construct of the Java programming language.

The simplest possible module declaration merely specifies the name of its module:

module com.foo.bar { }

The source code for a module declaration is, by convention, placed in a file named module-info.java at the root of the module’s source-file hierarchy. The source files for the com.foo.bar module, e.g., might include:

module-info.java
com/foo/bar/alpha/AlphaFactory.java
com/foo/bar/alpha/Alpha.java
...

A module’s declaration does not include a version string, nor constraints upon the version strings of the modules upon which it depends. This is intentional: It is not a goal of the module system to solve the version-selection problem, which is best left to build tools and container applications.

Module declarations are part of the Java programming language, rather than a language or notation of their own, for several reasons

157 questions
12
votes
2 answers

Java 9: Possible to have 2 modules with same name on module path

Is it possible to have 2 modules with the exact same name (but with slightly different contents) on the module path? As far as I can tell, the Java 9 compiler does not complain about it. I have 2 modules declared as follows: module com.dj.helper { …
DJ180
  • 18,724
  • 21
  • 66
  • 117
11
votes
3 answers

Does JPMS support module version?

I thought that JPMS doesn't support module version. However, when I do java --list-modules I have the following output: java.activation@9 java.base@9 java.compiler@9 java.corba@9 java.datatransfer@9 java.desktop@9 java.instrument@9 .... So, I…
Pavel_K
  • 10,748
  • 13
  • 73
  • 186
11
votes
2 answers

Failed to execute maven-compiler-plugin:3.6.1:testCompile when using java 9

I know that there are a lot question with similar error. I would appreciate before point as duplicate take in account that it only happens with Java 9. I do have java 9 installed C:\_pocs\ws_j9\java9-http-client>java -version java version…
Jim C
  • 3,957
  • 25
  • 85
  • 162
11
votes
1 answer

JPMS/Jigsaw Missing Main Class in Module

I'm trying to create a modular, executable jar file, that can be run with java -p -m on Java 9.0.1. This works as expected when creating a jar with jar cfe test.jar test.Main -C classes/ ., but throws module test does not have a…
kantianethics
  • 671
  • 5
  • 21
11
votes
2 answers

Is it possible to mix Java 8 and Java 9 source code in the same project without using compiler flags?

In Java 9, you can optionally package a source directory as a module by adding a module-info.java, which defines the things packages that it exports, and which other modules it depends on. Once you do that, however, you must list ALL dependencies in…
9
votes
1 answer

Can I use module-info.java if target level is 8?

I know that module-info.java is recognized by jdk9+ I wonder however whether module-info.java can still be used in combination with target level 8. E.g. I want my library to be used in java9+ projects, which will recognize it as a module exporting…
9
votes
3 answers

Which module should I require in Java 9 to use JPA?

I'm testing Java 9 with a project which requires JPA (javax.persistence.* classes). When I add the module-info.java and declare my module, all classes under javax.persistece package become unavailable. I searched a lot, but I couldn't find the…
Giovanni Lovato
  • 2,183
  • 2
  • 29
  • 53
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
7
votes
1 answer

Java 11 module-info and annotation processors

How can we provide an annotation processor with a Java 11 module? To register the annotation provider we need the following module-info entry: import javax.annotation.processing.Processor; import…
Puce
  • 37,247
  • 13
  • 80
  • 152
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
7
votes
1 answer

How to create jigsaw module in SBT?

I would like to use jlink for creating self-contained application packages for all platforms (darwin, linux, windows) from Scala source code. It seems that jlink only works with new (relatively) jigsaw modules - so I need to package my code as a…
vladimir
  • 2,635
  • 3
  • 23
  • 26
7
votes
3 answers

Error: Main.class found in top-level directory (unnamed package not allowed in module)

Trying to update an application to Java 11 and after sorting through hell with modules I thought I had got rid of all the red errors and now I'm getting this one I've never seen before: Looking around I've seen people suggest it is possible to do…
AlwaysNeedingHelp
  • 1,851
  • 3
  • 21
  • 29
7
votes
1 answer

List the modules resolved during the application startup

How can one get to know of the list of modules that have been resolved while the application has been started so as to figure out what all service providers are accessible from the root module.
Naman
  • 27,789
  • 26
  • 218
  • 353
7
votes
2 answers

SPI + JDK 9 + module-info.java

I am experimenting with SPI on JDK 9. Entire example works on JDK 9 without "module-info.java". After adding "module-info.java" ServiceLocator is not finding implementing class. I am confused and I cannot find working SPI example in modularized JDK…
6
votes
0 answers

JavaFX-11 error while deploying: module not found

I'm trying to deploy a very basic JavaFX application. I'm just creating a new JavaFX project and trying to deploy it to .exe but it gives me a module not found error. This is the console log: Buildfile:…
Hamlet
  • 307
  • 1
  • 8
1
2
3
10 11