You probably had installed a "headless" Java, i.e. without graphic libraries.
Headless mode is a system configuration in which the display device, keyboard, or mouse is lacking. Sounds unexpected, but actually you can perform different operations in this mode, even with graphic data.
That's why you had the java.awt.HeadlessException
when running the groovyConsole with it and why you solved the issue installing Oracle's JDK which is not headless (although you can run java programs in headless mode with java -Djava.awt.headless=true
).