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
1
vote
1 answer

Dependencies('requires' in module-info.java) not resolved when using custom configurations in build.gradle

For the following piece of code, the "requires org.postgresql.jdbc;" is unresolved when trying to perform Gradle-sync/assemble/build and using custom configuration 'driver' and custom sourceSet 'driver'. build.gradle plugins { id 'java-library' …
1
vote
2 answers

How to detect virtual threads on java 19

Lets say I want to ship a program that runs on java 17 as that is what is available widely, but use reflection to detect if im running on a vm with the ability to produce a thread factory via Thread.ofVirtual().name("abc").factory(). Java prohibits…
Dave Ankin
  • 1,060
  • 2
  • 9
  • 20
1
vote
0 answers

proguard module-info and jlink

Proguard does remove module-info in default. keep 'class module-info' Force proguard to keep the module-info class but it does not update the references inside to the obfuscated names, therefore jlink fails with "Package x.y.z not found in…
Lukas Hanacek
  • 1,364
  • 14
  • 25
1
vote
0 answers

Are non-exported packages still accessible from the unnamed module?

I am trying to restrict access to a package in my Java application using module-info.java. For the sake of simplicity, lets say I have the packages org.test.a, org.test.b and this module-info.class: module test { exports org.test.a; } I…
StudioCode
  • 33
  • 1
  • 4
1
vote
0 answers

How to run modular multi-package JUnit test suits?

I'm trying to run all tests (packaged across many different subpackages) in a given (Java-16, modular) project, using the test suite feature of JUnit (4); but this is much harder than I'd like if to be, seemingly requiring an -add-opens JVM option…
Arend
  • 2,363
  • 1
  • 18
  • 18
1
vote
1 answer

After modularizing my java project how can I reference org.apache.commons.* libraries

VSCode + Java 11 I am using the Apache commons libraries for a number of things in my project, specifically org.apache.commons.csv and org.apache.commons.io. I am including the jar files for both in my classpath and I was building just fine until I…
Simon
  • 78,655
  • 25
  • 88
  • 118
1
vote
0 answers

Java ERROR: package X is declared in the unnamed module, but module Y does not read it

I am trying to make my javafx project to create an Excel file. One of the first steps for it would be XSSFWorkbook workbook = new XSSFWorkbook(); for which to work I need import org.apache.poi.xssf.usermodel.XSSFWorkbook; to work. But when I try to…
Kuraj-a
  • 11
  • 2
1
vote
1 answer

Use encapsulated module in non modular Servlet based web app

I have an existing Java web app based on Servlets. It's an Eclipse project and it runs in Tomcat 10. The application doesn't use any Java 9+ modularization / JPMS up to now. The code base started at JDK 8 but now JDK 17 is used and works. Now I have…
MrSnrub
  • 1,123
  • 1
  • 11
  • 19
1
vote
1 answer

Java 11 + Gradle with modules + JavaFX + Tablesaw yields ResolutionException

Please forgive me in advance as I've been using Java since the early 2000s and have been slow to transition new projects toward being compliant with Project Jigsaw and modules (introduced in Java 9.) I'm stuck and hoping someone can help me out.…
Brian King
  • 71
  • 1
  • 6
1
vote
0 answers

IntelliJ JavaFX module-info.java: Module reads package 'javafx.fxml' from both 'javafx.fxml' and 'javafx.fxml'

I'm having problems using JavaFX in a uni project and I'm just going around in circles. I'm new to Java, JavaFX and IntelliJ so any help would be greatly appreciated! I initially set up a blank JavaFX project using the wizard in IntelliJ and then…
Wpitchy
  • 97
  • 6
1
vote
1 answer

How to fix unable to find module where it can be found under an incorrect name

I ran into an unusual problem using IntelliJ with a project, where when I clone the project from my GitHub repository, it would not run though it would build just fine. Then I discovered that when I ran the command mvn clean compile it would then…
Michael Sims
  • 2,360
  • 1
  • 16
  • 29
1
vote
0 answers

Maven will not compile project with module-info. Having 'cannot find symbol' and 'javafx package XY does not exist'

I am trying tu run mvn clean compile on my Eclipse project with module-info.java present. However the build ends up with many errors like: package javafx.XY does not exist (All referring to JavaFX packages) and can not find symbol ... (All referring…
Wortig
  • 963
  • 2
  • 11
  • 37
1
vote
5 answers

Eclipse asking for module named after the old project name

I'm trying to make my project modular on Eclipse, but I'm running into an issue. I have added the module-info.java file through right-clicking on the project > Configure > Create module-info.java. However, when I run, I get the error Error occurred…
Jak
  • 178
  • 10
1
vote
1 answer

error while exporting module in module-info.java -> Package is empty: projects

Before continuing, take a look on the image below: Any thoughts on why I'm unable to export the same module as my declared module in the module-info.java? P.S: The highlighted error message has nothing to do with this topic. But if you have any…
1
vote
1 answer

Module commons.math3 not found using jdeps

I'm using JDEPS to list the dependencies of libraries to ensure they are satisfied. I've recently upgraded from Apache POI v4.1.1 to v5.0.0, where JigSaw modules were added. Previously, the following command would output the dependencies: jdeps…
Jakg
  • 922
  • 12
  • 39