Using Apache Commons Numbers in a Java JDK 14 and Netbeans 12.1
I am developing some applications written in Java. For some functions I need to use the Apache Commons library.
Previously, I was using Netbeans 12.0 and all was OK.
Description of the new problem.
I have created a global library (Commons-numbers) including
commons-numbers-complex-1.0-beta1.jar
The targeted project (a Java Modular Project), in my case « pacte-basics », includes the path to this global library in the Modulepath (Project Properties/Libraries/Compile)
That yields to strange error messages :
error: duplicate module on application module path
module in commons.numbers.field
error: duplicate module on application module path
module in commons.numbers.angle
...
Solution
Download the source version of the Apache Commons Numbers library.
Create a Java Modular Project, in my case « Apache-Commons »
Create a Module, in my case « commons.numbers ». The use of module paths is useful in case of numerous modules.
Create the associated package org.apache.commons.numbers.complex, to be compatible with future Apache Commons libraries that will solve the problem.
Import all needed sources, in my case Complex.java
Modify the module-info.java class to correspond to,
module commons.numbers {
exports org.apache.commons.numbers.complex;
}
Clean and Build, the Project Apache-Commons
In the targeted Modular Module, in my case « pacte-basics », add the project « Apache-Commons » in the Libraries properties, Modulepath, using Add Project.
Each modules using « numbers » must include in its module-info.java, the line
requires commons.numbers;
For the case of Commons IO, that need further source files to satisfy dependencies.