RubyGems is just a Ruby library. The gem command is just a thin shell around the library. All that you can do with the command, you can do with the library.
I never used the library, but I think that you want to look, this is Gem :: DepencyInstaller , and the code will look something like this (completely untested, just pulled out of you-know-what):
ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine jRubyEngine = manager.getEngineByName("jruby"); String s = " require 'rubygems' require 'rubygems/dependency_installer' Gem::DependencyInstaller.new.install('cucumber') "; jRubyEngine.eval(s);
Jรถrg W Mittag
source share