You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

JDK 10与Oxygen 3a环境下Selenium包冲突问题求助

解决JDK 10 + Oxygen 3a中WebDriver导入的模块冲突问题

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 the selenium-client-combined-*.jar (which includes embedded Guava classes) and a standalone guava-*.jar added. 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 a module-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-*.jar
    • selenium-api-*.jar
    • selenium-chrome-driver-*.jar (or the driver for your preferred browser)
      Then update your module-info.java to 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 → PropertiesJava Build PathModules tab:

    • Make sure all Selenium jars are correctly marked as either Automatic Modules (for non-modular jars) or Named Modules (for modular ones).
    • Scan for any duplicate modules listed here and remove the extras.
  • 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 to Run AsRun ConfigurationsArguments tab, and add this to the VM arguments field:

    --illegal-access=permit
    

    Note 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

火山引擎 最新活动