I am creating my first project using JPMS . Simply I have a Maven project and some simple classes that need JAXB classes.Then
created module-info.java
module mymodule{
requires jakarta.xml.bind; requires java.base; requires java.xml; }
added JAXB dependencies in pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>savino.prove.view</groupId>
<artifactId>View</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>20</maven.compiler.source>
<maven.compiler.target>20</maven.compiler.target>
<exec.mainClass>savino.prove.view.View</exec.mainClass>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>4.0.0</version>
<type>jar</type>
</dependency>
<!-- JAXB Implementation -->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>4.0.2</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>20</source>
<target>20</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
but on JAXBUtils class I got compilation error :
package jakarta.xml.bind is not visible (package jakarta.xml.bind is declared in the unnamed module, but module mymodule does not read it
nevertheless I see jakarta.xml.bind package in the dependency and also (for example) JAXBContext class . ALso ,maven use correctly the module path parameter :
Command line options: -d /home/devuser/work/Prove/CSGView/View/target/classes -classpath /home/devuser/work/Prove/CSGView/View/target/classes: --module-path /home/devuser/.m2/repository/jakarta/xml/bind/jakarta.xml.bind-api/4.0.0/jakarta.xml.bind-api-4.0.0.jar:/home/devuser/.m2/repository/jakarta/activation/jakarta.activation-api/2.1.0/jakarta.activation-api-2.1.0.jar: -sourcepath /home/devuser/work/Prove/CSGView/View/src/main/java:/home/devuser/work/Prove/CSGView/View/target/generated-sources/annotations: -s /home/devuser/work/Prove/CSGView/View/target/generated-sources/annotations -g -target 20 -source 20 -encoding UTF-8 --module-version 1.0
I saw this Baeldung JPMS example, and starting investigate my problem also with this example because it report same errors underlined by NB Ide ,but the mainappmodule is working, I can run it !
Then is just NB showing wrong compile errors ?
Look the image :

