Here’s the code sample from our tutorial on how to execute your tests in headless mode in Selenium for Java