Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Java9 mdoule - Problem between classpath / module-path(Eclipse mixes-up classpath and module-path)
Java9 mdoule - Problem between classpath / module-path [message #1785324] Thu, 12 April 2018 13:22 Go to next message
Colbert Philippe is currently offline Colbert PhilippeFriend
Messages: 1
Registered: April 2018
Junior Member
I'm trying to use Eclipse (4.8M4) with Maven to practice Java9 module.

I already contacted Maven to ask what version of Maven to use with Java 9 module feature. They recommended the latest version: Maven 3.5.0 (latest) with the Maven plug-in: maven-compiler-plugin 3.7.0, which is what I'm using. I'm also using Java JDK 9.

I want to report a problem with Eclipse when working with Java 9 module feature. It's not a big problem but it's big enough to prevent the use of Eclipse with Java 9 modules. The problem is with Eclipse, not Maven. The Maven version that I'm using works fine! I tested it!

I created two identical projects with Java 9 module. The two projects make use of a few old-style Jar files by importing them as default module (as prescribed by the makers of Java 9). The jar files are: ant.jar, commons-beanutils-1.9.3.jar, commons-collections4-4.1.jar, commons-lang3-3.7.jar.

* The first project is a small project built from the command-line with a text-editor. It's a Java 9 module project (has a module-info.java) and makes use of these 4 libray jar files in the matter prescribed by the Java 9 documentation. This project compile and works. All Jar files are put the the module-path of the project and their respective 'requires' statement is in the module-info.java file. (see below)

module canada.ontario {
exports canada.ontario;
requires org.apache.commons.lang3;
requires commons.collections4;
requires commons.beanutils;
}

** The second project is identical to the first one but is built using Eclipse & Maven (versions specified above). The project as created as intended with Maven. First a parent project was created with packaging set with pom. The a child-project was created for the module.

After the child-project was created, in the child-project POM file, I entered the full plug-in entries to use the new 'maven-compiler-plugin' version 3.7.0. This works because we can see its use on the compiling log display messages.

On Eclipse Workspace view, I selected the parent project root (previously created), right clicking on the parent project, then selecting 'Maven', then selecting 'New Maven Module Project'. This creates a Maven child project for the new module.

- I created a 'module-info.java' with the name of the module (canada.ontario) in the src directory.
- I also created a package with the same name as the module (canada.ontario).
- I entered the same 'exports' and 'requires' statements as displayed above.
- I also entered all the Maven dependencies to each of the four (4) libraries stated above. I got these dependencies from the Maven repository.
- I also enabled full compile-time log-message diplay, in order to get maximum information.

### HERE IS THE PROBLEM WHEN COMPILING THIS SECOND MAVEN CHILD-PROJECT! ###

When compiling the second child-project for the module, there is an error. I have narrowed down the reason for the errror.

For some unknown reason, the Maven compiler plug-in DOES NOT put all the jar dependencies under the module-path. It splits the list of dependencies between the classpath and the module-path, WHICH IS WRONG! (see below)

[INFO] Changes detected - recompiling the module!
[DEBUG] Classpath: <----- There should be no jar under this Classpath list ***
[DEBUG] C:\Users\Colbert Philippe\workspace\montreal\quebec.lachine\target\classes
[DEBUG] C:\Users\Colbert Philippe\.m2\repository\org\apache\commons\commons-collections4\4.1\commons-collections4-4.1.jar
[DEBUG] C:\Users\Colbert Philippe\.m2\repository\commons-beanutils\commons-beanutils\1.9.3\commons-beanutils-1.9.3.jar
[DEBUG] C:\Users\Colbert Philippe\.m2\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar
[DEBUG] C:\Users\Colbert Philippe\.m2\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar
[DEBUG] Modulepath: <----- All jar file dependencies should be under this ModulePath list ***
[DEBUG] C:\Users\Colbert Philippe\.m2\repository\org\apache\commons\commons-lang3\3.7\commons-lang3-3.7.jar
[DEBUG] Source roots:

This is the source of the error!

Since putting all the jar files under module-path works in my first hand-created project works fine. I am certain that this is the cause of the error.
Re: Java9 mdoule - Problem between classpath / module-path [message #1785353 is a reply to message #1785324] Thu, 12 April 2018 21:10 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1627
Registered: July 2009
Senior Member
How did you invoke the build, by which the shown DEBUG output was created?

If that's a regular Maven build, then how could Eclipse possibly be at fault?

If it is a build driven by m2e, then you should ask on their mailing list.
Previous Topic:Cannot create a new project in Force.com IDE
Next Topic:How to find import statements that are required for the block in AST Eclipse JDT?
Goto Forum:
  


Current Time: Thu Sep 20 00:03:51 GMT 2018

Powered by FUDForum. Page generated in 0.02118 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top