Search code examples
eclipsejarjava-11java-platform-module-system

Having (old) jars on the classpath of a JDK 11 project [eclipse]


I've finally tried to set up a modularised Java project with JDK 11, but I don't seem to be using the module and classpath properly. So far, I have done nothing but create the project and add the Apache Commons IO 2.6 to its classpath. The module file is still empty.

Then I created a test class and used one of the Apache classes and that's where it gets confusing to me. Eclipse's auto-completion offers me the Apache classes fine and even adds the import as it should, but then the same import cannot be resolved.

Check the screenshots below to see what I mean.

The Module and the Class Path

Auto-Completion Works Fine

Import Cannot be Resolved

Any help is appreciated :)


Solution

  • Based on Slaw's comment, the following tweak worked for me:

    • Add the jar on the module path.
    • Add the Apache Common's 'auto module' (i.e. the default module?) in the module-info file, in this case: requires org.apache.commons.io;