This is the right way but there's a small typo in your :java_args
, it should be:
test.using :java_args => [ '-Djava.awt.headless=true' ]
(notice the equal sign after headless
versus a colon in your question.)
There is also a more concise/foolproof way of passing properties
using a hash of property names and values,
test.using :properties => { "java.awt.headless" => "true" }