Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Selenium’s Java TakesScreenshot API to save a screenshot of the current browser context, and run Chrome headlessly with ChromeOptions on a Linux VPS. The example below saves a PNG using Java NIO and closes the browser even if navigation or file writing fails. It captures the current viewport; it does not, by itself, guarantee a full-page screenshot.

What you need

  • A Java application with Selenium Java on its classpath.
  • Google Chrome installed on the VPS, plus the operating-system libraries that browser needs.
  • A Linux service account that can launch the browser and write to the screenshot destination.

Selenium Manager, included with Selenium releases from version 4.6, can manage a browser driver as a fallback when you have not supplied one yourself. Its binaries support Linux. ChromeDriver is a separate executable used by Selenium to control Chrome; for troubleshooting, check that the Chrome and ChromeDriver major versions match. See Selenium’s Selenium Manager documentation and ChromeDriver getting-started guide.

Capture a screenshot with Java

Add Selenium Java to your project using the dependency manager and version appropriate for your application. This standalone example uses Java NIO, so it does not require the Apache Commons IO helper used in Selenium’s documentation example.

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;

import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class ScreenshotPage {
    public static void main(String[] args) throws Exception {
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--headless=new");
        options.addArguments("--window-size=1440,1000");

        WebDriver driver = new ChromeDriver(options);
        try {
            driver.get("https://example.com");

            Path destination = Path.of("/tmp/example.png");
            Files.copy(
                ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE).toPath(),
                destination,
                StandardCopyOption.REPLACE_EXISTING
            );
            System.out.println("Saved screenshot to " + destination.toAbsolutePath());
        } finally {
            driver.quit();
        }
    }
}

Replace the example URL and destination with your own. The output type is PNG. The explicit window size makes the viewport more predictable, but does not make the capture full-page. Choose a destination the process can write to. Selenium’s Java screenshot example uses the same TakesScreenshot and OutputType.FILE approach; see Working with windows and tabs — TakeScreenshot.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Configure Chrome for headless Linux

Pass ChromeOptions to ChromeDriver, as in the sample. Selenium’s Chrome-specific documentation lists --headless=new among common arguments; confirm that the installed Chrome version supports it. If it does not, use a headless argument supported by that version rather than assuming every VPS image has the same browser build. Refer to Selenium’s Chrome-specific functionality guide.

Headless mode removes the need for a graphical desktop, but it does not remove Chrome’s operating-system dependencies. If Chrome fails to start with a missing shared-library error, use the exact library name in the error to diagnose the VPS image. Selenium Manager’s Linux documentation includes examples of such errors for browsers; avoid blindly installing a package list intended for a different distribution.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Decide what the screenshot should include

Current viewport

The basic TakesScreenshot call captures the current browsing context. Set the window dimensions before navigation if the viewport must be consistent, and wait for the page state your task needs before taking the shot. A page that has not finished rendering, or content that loads after the initial navigation, may not appear in the image.

A single element

Selenium also documents element-level screenshot capture. Use that when the requirement is one visible element rather than the browser viewport; consult the Selenium screenshot documentation for the API example. Element capture is a different scope from capturing the current browsing context.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Entire scrollable page

Do not treat the sample as a full-page capture. The cited Java example does not establish that it captures content beyond the viewport. If the whole page is required, select and verify a full-page method supported by your chosen browser and Selenium version, and test it on pages with long content and lazy-loaded images.

Deploy it on an Indian Linux VPS

The steps below apply to an Indian-hosted Linux server in general; no particular provider, city, plan, operating-system image, or price is established here. Validate regional availability and technical fit with the VPS provider before choosing a service.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
  1. Check the server image. Confirm that the Linux distribution can run your Java runtime, Chrome build, and required browser libraries.
  2. Check browser and driver startup. Run the application as the same service user that will take screenshots. If session creation fails, inspect both browser and driver versions and their startup logs.
  3. Check permissions. Make sure the service user can write to the configured output path and that the destination has enough storage for your retention needs.
  4. Check network access. Confirm the server can reach the target site over the required outbound routes. A site may also behave differently when accessed from the VPS’s location.
  5. Plan for your workload. Assess CPU, memory, storage, and bandwidth against the concurrency and page complexity you actually expect; no universal VPS resource minimum is established for this workload.
  6. Keep diagnostics. Retain application and browser startup logs so you can distinguish driver, library, permission, network, and page-readiness failures.
  7. Coordinate updates. Keep Chrome and ChromeDriver compatible when updating either component.

Troubleshoot common failures

Symptom Likely cause What to check
Chrome session fails to start Chrome and ChromeDriver major versions do not match, or Chrome cannot launch in the server environment. Check both versions, the browser startup error, and whether Chrome’s required libraries are installed.
Driver executable cannot be found No driver was supplied and automatic management did not complete, or the driver is unavailable in the environment. Check Selenium Manager diagnostics and network access; alternatively, configure a compatible driver explicitly.
Missing shared-library error A required operating-system library is absent from the VPS image. Use the library named in the actual error to identify the matching package for that Linux distribution.
Screenshot is missing or cannot be saved The process cannot write to the chosen directory, or the file operation failed. Check the service user’s permissions, destination path, available storage, and application exception logs.
Image is blank or content is absent Navigation may not have reached the needed page state, content may load later, or the site may respond differently to the server request. Log the current URL and page state, wait for the required content, and check outbound access and site behavior.
Only the visible portion appears The basic screenshot call captures the current browsing context, not necessarily the full scrollable document. Use a verified full-page capture method for the selected browser and Selenium version.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and cost considerations

Launching a browser and loading a page are part of the work, so measure the end-to-end time and resource use on your actual VPS and pages before selecting concurrency. Keep browser sessions short-lived where appropriate and always call quit() in a finally block to reduce the chance of orphaned browser processes after an exception. No fixed performance figure or VPS resource minimum applies to all sites and workloads.

Account for failures beyond Java code: browser startup, missing libraries, permissions, network access, and pages that do not reach the state you need. Log enough context to diagnose those conditions without recording sensitive page data or credentials.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Or skip the browser setup

If you need a screenshot endpoint instead of maintaining Chrome and Selenium on a VPS, ScreenshotNeo is a website screenshot API and MCP server. Its API accepts one GET request with a URL and can return PNG, JPEG, WebP, or PDF. For Java, use a standard HTTP client or Java’s built-in HttpClient to make the same request; the cURL, Python, and Node.js examples below show the endpoint and parameters.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo API documentation for request options and response details. Cookie banners are accepted and removed before capture, along with known newsletter popups and chat widgets; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, with response headers indicating the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.

Frequently Asked Questions

Does Selenium’s Java screenshot call capture the full page?

No full-page behavior is established by the documented current-context example; verify a separate full-page approach for your browser and Selenium version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can Selenium Manager manage ChromeDriver on Linux?

Selenium Manager is a built-in fallback in Selenium releases from version 4.6, and its binaries support Linux.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.