1

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 put my code in a Java module for packaging.

Now I get import errors saying the packages are inaccessible, such as org.apache.commons.csv is not accessible.

If I try and refer to them directly in my own module-info.java like this...

module com.hupa {
    exports com.hupa.alg.cluster;
    requires jdk.xml.dom;
    requires org.apache.commons.csv;
}

I get the error org.apache.commons.csv cannot be resolved to a module, which seems correct as there is no module defined for it.

I am at a bit of a loss about what to do. There is no module-info.java or module-info.class in the jars I have for these libraries. How am I supposed to refer to them as dependencies for my project?

Simon
  • 78,655
  • 25
  • 88
  • 118
  • quick update, Java 11 is irrelevant. I have tried with later version of Java up to 18 and have the same issue. – Simon Sep 19 '22 at 01:26

1 Answers1

0

This could be helpful.

How to use 3rd party library in Java9 module?

The solution mentioned works for commons.csv. I'm using eclipse and maven for dependencies. Eclipse shows following warning though.

Name of automatic module 'commons.csv' is unstable, it is derived from the module's file name.

kph
  • 1
  • 1