JDK 10与Oxygen 3a环境下Selenium包冲突问题求助
Hey there, let's break down what's happening and fix this module conflict error you're seeing.
First, the root cause: Java 9 introduced the Java Platform Module System (JPMS), and JDK 10 tightened up the rules around package accessibility. The error The package org.openqa.selenium is accessible from more than one module: client.combined, com.google.common means two different modules on your module path are exporting the same org.openqa.selenium package—this confuses the module system, which expects each package to belong to exactly one module. JDK 9 was a bit more lenient here, which is why your code worked before.
Here are the step-by-step fixes you can try:
Clean up duplicate dependencies
Double-check your module path: you likely have both theselenium-client-combined-*.jar(which includes embedded Guava classes) and a standaloneguava-*.jaradded. The combined Selenium jar already has all the Guava components it needs, so having the standalone one creates the package overlap. Remove the standalone Guava jar, leaving only the combined Selenium jar in your module path.Switch to modular Selenium dependencies (recommended)
If your project uses amodule-info.java(a modular project), it's better to use Selenium 3.141.59 or later—these versions are fully JPMS-compatible and split into proper modules instead of a single combined jar. Replace the old combined jar with split modules like:selenium-java-*.jarselenium-api-*.jarselenium-chrome-driver-*.jar(or the driver for your preferred browser)
Then update yourmodule-info.javato declare the required modules:
module your.project.module { requires org.openqa.selenium.selenium.api; requires org.openqa.selenium.selenium.java; requires org.openqa.selenium.selenium.chrome.driver; // Add other driver modules if you use Firefox, Edge, etc. }Tweak Oxygen's module path configuration
In Oxygen 3a, right-click your project →Properties→Java Build Path→Modulestab:- Make sure all Selenium jars are correctly marked as either
Automatic Modules(for non-modular jars) orNamed Modules(for modular ones). - Scan for any duplicate modules listed here and remove the extras.
- Make sure all Selenium jars are correctly marked as either
Temporary workaround (not recommended for long-term use)
If you need a quick fix to unblock yourself, you can loosen the module system's access rules by adding a VM argument. Go toRun As→Run Configurations→Argumentstab, and add this to theVM argumentsfield:--illegal-access=permitNote that this is a stopgap—future JDK versions might remove this flag, so it's better to use one of the permanent fixes above.
内容的提问来源于stack exchange,提问作者Hima




