Nathan Ridley’s answer to another similar question is the most complete one I’ve found so far.
Anyway, if everything fails, you could use a Python or JS alternative, expose its funcionality as a webservice inside your server, and then your Java application could use the headless browser’s funcionality through the webservice. It would be a pain to set up, but it may be a viable alternative if nothing else works as desired.
Also, there are some “non-headless” browser wrappers for Java; maybe it would be possible to build a testing solution around those, depending on the requirements.