Improve Java version detection

Java on most (all?) platforms directs `-version` to STDERR rather than
STDOUT.