ChromeOptions options = new ChromeOptions(); WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444"), options); Instead of managing JAR manually, use Selenium Docker images:
wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.28.1/selenium-server-4.28.1.jar (Replace version with the latest) Basic standalone (Hub + Node in one): java -jar selenium-server-<version>.jar standalone This starts a server on http://localhost:4444 that can launch local browsers. Run as a Grid Hub: java -jar selenium-server-<version>.jar hub Hub URL: http://localhost:4444 Run as a Node (register to a Hub): java -jar selenium-server-<version>.jar node --hub http://localhost:4444 4. Using with RemoteWebDriver (Java example) Once the server is running ( standalone mode or Hub+Node), connect to it: selenium server standalone jar
For modern Selenium 4, use BrowserOptions instead of DesiredCapabilities : ChromeOptions options = new ChromeOptions()
Or via command line:
import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.remote.DesiredCapabilities; import java.net.URL; public class RemoteTest public static void main(String[] args) throws Exception WebDriver driver = new RemoteWebDriver( new URL("http://localhost:4444"), DesiredCapabilities.chrome() ); driver.get("https://www.google.com"); System.out.println(driver.getTitle()); driver.quit(); Instead of managing JAR manually