Minimal Java installation for Linux with no GUI
I don't know CentOS, but usually their is an OpenJDK -headless
package in distributions that doesn't include GUI components, and normally no dependencies to X11 packages.
For instance debian provide one package and ArchLinux too. If your distribution doesn't include it, you can maybe have a look at these to see how it is build.