Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsSome links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
If java.awt.Robot.createScreenCapture() returns a blank or gray image in a PuTTY-based remote session, start by checking the display session Java can access—not the PNG or JPEG encoder. Confirm that Java is not running headless, can access the desktop where the target UI is drawn, and is capturing a rectangle inside that display’s bounds. Then isolate X11 compositing and the later image-writing pipeline. There is no single PuTTY setting established as a fix for every such failure.
Why can Java Robot return a blank screenshot over SSH?
Robot captures pixels from a screen rectangle in the coordinate system of the display available to the Java process. It does not inspect an application’s internal UI model or automatically find a window by name. If the process is attached to a different display, lacks permission, or uses coordinates outside the visible screen, the image may not show the UI you expect. Oracle describes createScreenCapture(Rectangle) as creating an image containing pixels read from the screen: Java SE 11 Robot API.
A call that returns an image is not proof that its pixels are valid. The API notes that desktop restrictions can cause an access exception or leave the captured contents undefined. A uniform gray image therefore does not, by itself, identify whether the problem is permissions, display selection, coordinates, or a compositor.
PuTTY is an SSH and telnet client; its presence in the connection path does not establish that it caused the image failure. Also, do not assume PuTTY itself supplies an X server. The exact client platform, X server, desktop, and session setup matter. PuTTY’s project describes the software at putty.org.
#1 Best Overall
- KEYBOARD: The keyboard works for Windows with hot keys that enable easy access to Media, My Computer, Mute, Volume up/down, and Calculator
- EASY SETUP: Experience simple installation with the USB wired connection
- VERSATILE COMPATIBILITY: This keyboard is designed to work with multiple Windows versions, including Vista, 7, 8, 10 offering broad compatibility across devices.
- SLEEK DESIGN: The elegant black color of the wired keyboard complements your tech and decor, adding a stylish and cohesive look to any setup without sacrificing function.
- FULL-SIZED CONVENIENCE: The standard QWERTY layout of this keyboard set offers a familiar typing experience, ideal for both professional tasks and personal use.
Check headless mode and whether Robot can be constructed
Headless execution is a separate, decisive case. Oracle’s Java SE 11 documentation says constructing Robot always throws AWTException when GraphicsEnvironment.isHeadless() returns true. Check this before debugging image formats. If the Java process is headless, it has no usable screen for this capture route; run it in an environment with an accessible display or use an application-level export or test interface instead.
This small diagnostic logs headless status, attempts construction, prints the available screen devices and bounds, and captures a caller-specified rectangle. Compile it with a JDK and run it in the same shell, user account, and session context as the application. Pass coordinates and dimensions only after checking the actual desktop bounds.
import java.awt.AWTException;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;
public class RobotScreenCheck {
public static void main(String[] args) throws Exception {
System.out.println("headless=" + GraphicsEnvironment.isHeadless());
if (GraphicsEnvironment.isHeadless()) {
System.err.println("No graphical screen is available to this Java process.");
return;
}
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] devices = ge.getScreenDevices();
for (int i = 0; i < devices.length; i++) {
System.out.println("device[" + i + "]=" + devices[i].getIDstring()
+ " bounds=" + devices[i].getDefaultConfiguration().getBounds());
}
if (args.length != 5) {
System.err.println("Usage: java RobotScreenCheck x y width height output.png");
return;
}
int x = Integer.parseInt(args[0]);
int y = Integer.parseInt(args[1]);
int width = Integer.parseInt(args[2]);
int height = Integer.parseInt(args[3]);
if (width <= 0 || height <= 0) throw new IllegalArgumentException("Width and height must be positive");
Rectangle area = new Rectangle(x, y, width, height);
System.out.println("capture=" + area + " toolkit screen=" + Toolkit.getDefaultToolkit().getScreenSize());
try {
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(area);
System.out.println("image=" + image.getWidth() + "x" + image.getHeight()
+ " sample(0,0)=0x" + Integer.toHexString(image.getRGB(0, 0)));
if (!ImageIO.write(image, "png", new File(args[4]))) {
throw new IllegalStateException("No PNG writer is available");
}
System.out.println("wrote " + args[4]);
} catch (AWTException e) {
System.err.println("Robot construction failed: " + e);
throw e;
}
}
}
For example, compile with javac RobotScreenCheck.java, then run java RobotScreenCheck 0 0 800 600 robot.png only if those coordinates correspond to a visible 800-by-600 area on the display. A single sampled pixel is not a quality test: compare several known points or open the saved image. The code is a diagnostic, not proof that any particular PuTTY or server configuration is correct.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
- All-day Comfort: The design of this standard keyboard creates a comfortable typing experience thanks to the deep-profile keys and full-size standard layout with F-keys and number pad
- Easy to Set-up and Use: Set-up couldn't be easier, you simply plug in this corded keyboard via USB on your desktop or laptop and start using right away without any software installation
- Compatibility: This full-size keyboard is compatible with Windows 7, 8, 10 or later, plus it's a reliable and durable partner for your desk at home, or at work
- Spill-proof: This durable keyboard features a spill-resistant design (1), anti-fade keys and sturdy tilt legs with adjustable height, meaning this keyboard is built to last
- Plastic parts in K120 include 51% certified post-consumer recycled plastic*
Verify display access and screen coordinates
Run the Java process where the target interface is actually rendered and check that the session authorizes that process to access the display. The API documents that desktop access restrictions can result in SecurityException or undefined captured contents. If a capture throws, record the complete exception. If it returns a uniform image, check the visible desktop and authorization path rather than assuming the return value confirms access.
Use the diagnostic output to compare the capture rectangle with device bounds. Multi-monitor layouts may place devices in different coordinate spaces; screen origins need not all be at (0, 0). A rectangle with positive width and height can still point at the wrong monitor or an off-screen region. First test a small area that you can positively identify on the display Java sees.
Separate screen capture from image encoding
Inspect the BufferedImage immediately after createScreenCapture, before saving, uploading, resizing, or transmitting it. Open the PNG written directly by the diagnostic and compare it with the pixels logged or sampled in memory. If the in-memory image is already blank or gray, focus on display selection, permissions, bounds, and the X11/compositor path. If it looks correct in memory but is wrong after another stage, isolate that later stage: compare the direct PNG with the transformed or transmitted result and check format handling, resizing, and transport independently.
Rank #3
- A plug-and-play USB connection with Low-profile keys give you a quiet, comfortable typing experience
- Simple Wired USB Connection,You will enjoy a comfortable and quiet typing experience
- The keyboard for business and office working is the budget-friendly keyboard that is built for longer use
- Low profile keys for a more comfortable and quiet keystroke, desktop-centric design, splash resistant
Investigate X11 capabilities and compositing when relevant
On X Window systems, Oracle documents XTEST 2.2 support as one possible requirement for Robot construction and low-level input. If new Robot() fails or Robot input operations fail, investigate whether the X server supports and enables the relevant XTEST capability. XTEST is not itself an explanation for every gray screenshot: input support and correct screen-pixel capture are related but distinct questions.
Recommended Free Tools
Compositing is another specific possibility. OpenJDK issue JDK-8150954 records an X11 case where the root window did not contain the final composited desktop, resulting in incorrect screen captures with black areas: OpenJDK issue JDK-8150954. If the target is a composited X11 desktop and captures contain missing or black regions, compare the captured result with the visible desktop and investigate which screen surface the capture path exposes. That report documents a particular mechanism, not a universal cause of blank or gray images.
Check the PuTTY session last, using its actual setup
Once you know Java is non-headless, identify the display it can access, and have checked permissions and capture bounds, examine how this particular PuTTY session connects to the graphical desktop. Verify the actual SSH client platform, X server or desktop environment, display authorization, and the command or service context used to launch Java. Do not copy an unverified environment variable or guessed X11-forwarding control as a universal fix: the necessary setting depends on the session, and a reliable exact PuTTY configuration cannot be prescribed without those details.
Rank #4
- Durable and Reliable: This USB keyboard features a curved space bar, spill-resistant design (2), durable keys that can withstand 10 million keystrokes, and sturdy, adjustable tilt legs
- Comfortable, Familiar Typing: You’ll enjoy a comfortable and familiar typing experience thanks to the deep-profile keys and standard layout with full-size F-keys and number pad
- Full-size Sculpted Mouse: The high-definition optical USB mouse puts comfort and control in your hands with smooth, accurate tracking and an ambidextrous shape that feels good hour after hour
- Simple Set-Up: Simply plug the keyboard and mouse into the USB ports on your desktop, laptop, or netbook and you're ready to work; compatible with Windows 7, 8, 10 or later
- Clear and Convenient: The bold, bright white and long-lasting characters make the keys on this PC or laptop keyboard easy to read and extra durable
Useful details to collect when asking for help are the operating system and desktop, JDK vendor and version, PuTTY version, whether the display path is X11 or another system, how Java is launched, the full exception (if any), the device bounds, and whether the bad image is uniformly gray or only a window or region is wrong.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Symptom-to-check guide
| Observation | Check first | What it indicates |
|---|---|---|
new Robot() throws AWTException |
Headless status, display availability, and—on X Window systems—XTEST support | Headless mode guarantees this constructor failure; XTEST may matter for low-level Robot operation on X Window systems. |
Capture throws SecurityException |
Desktop screen-access restrictions and process authorization | The API documents screen-access denial as a possible exception. |
| Capture returns an image, but it is uniform or undefined | Which display the process sees, screen access, rectangle bounds, and compositor | A successful return does not guarantee defined pixels; restricted access and a specific X11 compositing issue are documented possibilities. |
| Only one area is missing or misplaced | Rectangle origin, dimensions, device bounds, and monitor coordinate layout | Robot uses display coordinates; the rectangle may target another or off-screen area. |
| In-memory image looks right, saved or transmitted image does not | Serialization, resizing, conversion, or transfer after capture | The discrepancy points to a later pipeline stage, so isolate it before changing display settings. |
Or skip the browser setup
For a website capture rather than an interactive desktop capture, ScreenshotNeo offers a one-request API. This does not replace Java Robot for capturing an arbitrary desktop or application window; it captures a URL as a website screenshot. See the ScreenshotNeo API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and whether the request was billed. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Those features are available on every plan. Learn about ScreenshotNeo or sign up for 1,000 free screenshots a month with no card.
FAQ
Does PuTTY X11 forwarding affect Java Robot screenshots?
It can be part of the display path, but the information available here does not establish a PuTTY-specific setting that fixes all captures. First determine which graphical display Java can access, whether the process has authorization, and whether the requested rectangle maps to the intended screen.
Best Value
- The Lenovo 300 USB keyboard offers an intuitive and comfortable island key design with 2 5 zone layout including separate number pad
- This full-size keyboard includes concaved key caps fitted for your fingertips
- Spill resistant keys with a board drain help keep your PC keyboard protected and keep you productive
- The complete ergonomic design includes an adjustable tilt to improve your typing comfort
- OS independent – This convenient computer keyboard works with laptops desktops and any computer with a USB port
Can Robot capture an application’s UI when Java is headless?
No screen pixels are available to that process through this Robot route when the environment is headless. Use a process with access to a real graphical display, or an application-level export or test interface.
Does an XTEST problem explain a gray image?
Not by itself. XTEST support is a diagnostic when Robot construction or low-level input fails on X Window systems; it does not establish the cause of every incorrect capture.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Quick Recap
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.

