Add better support for JRuby and fix the `ps` calculation