From here:
What is headless Java?
Java’s graphics capabilities were originally intended for client machines, which have built-in graphics cards. So, the initial Java implementation assumed that requests to create graphics could make use of the graphics card of the machine on which Java was running. As Java became a server-side technology, graphics creation also moved to the server. Then it became useful to create graphics in memory on servers. Those graphics could be saved in files or sent over the network to be displayed on other machines. However, servers often do not have graphics cards. They are often administered remotely without using attached displays. So, Java could no longer assume that it was running on a machine that had graphics hardware. Java was redesigned to allow some, but not all, graphics functions to be performed in a headless environment. As a result, some Java graphics functions now work without using a graphics device.