javaeclipseclasspathjava-modulemodule-path

In Eclipse, what is the difference between modulepath and classpath?


In Eclipse, what is the difference between modulepath and classpath, and which one should I use to add a JAR file in the lib folder?

And why does the JRE System Library appear in modulepath?


Solution

  • The module system has mainly the following impact on the code:

    All code that is on the classpath lives together in the "unnamed" module. All code on the modulepath lives in their own "named" modules.

    You have to distinguish two cases:

    The JRE is always on the module-path, so that its internal code cannot be accessed even from code on the classpath.

    There is one special case: If you have a module-info.java in your project and have test code in your project, you usually don't want to mention test dependencies like junit in the module-info.java. There are two solutions for this:

    In Eclipse Oxygen, the Maven solution was not possible, because it has no notion which code is test code, but this has been implemented in the upcoming Eclipse Photon (4.8) release, which will be out in June. You can already work with the (feature-complete) milestone builds from http://download.eclipse.org/eclipse/downloads/. In case you find any bugs, please report them at https://bugs.eclipse.org/bugs/.