Fix system command in JRuby

by passing ENV vars as the first arg to system as a hash, which is the
recommended way.
Also, clean up some code.