Eclipse cannot build, but maven can since moving from Java 8 to Java 11

electroCutie :

Here is the minimal reproduction

I'm using Eclipse Version: 2019-03 M1 (4.11.0 M1), Build id: 20190117-2133

The jars in question are Selenium, but they are the only ones in the main project which are multi-release jars, so I think that may be part of the problem

Basically, Eclipse has an error on build

selenium.firefox.driver cannot be resolved to a module

and all imports of the classes under that module give the error

The import org.openqa.selenium cannot be resolved

Or some variation thereof. Sometimes it is org that it claims to not be able to resolve

Importantly, this does successfully compile under Maven

Jens Dibbern :

You can use Selenium with Java 11. Just can remove Selenium from your module_info.java and use it as an additional jar file.

If you want to use Selenium as a Java module, you have to edit your project setup and add Selenium to your Modulepath like that:

Eclipse Modulepath setup

Unfortunately the Maven plugin seems to ignore this during an Eclipse project update (not only with Selenium).

To get this fixed, I had to modify the module-info.java as well:

module browserAutomation{

  requires org.openqa.selenium.core;
  requires org.openqa.selenium.firefox;

}

This is corresponding to the source code at https://github.com/SeleniumHQ/selenium/tree/master/java/client/src/org/openqa/selenium

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=160703&siteId=1