I'm trying to execute a .jar file from ruby and read the output. The following solution works when my .jar file does not expect any parameters to be passed. But when I try to do this, I get an error -
pipe = IO.popen( [ '/path/to/java', '-jar', "/path/to/jarfile.jar #{argsA} #{argsB}", {SDTERR=>STDOUT} ]
pipe.close_write
puts pipe.readlines
I need to pass a couple of parameters to the .jar file. How can I acheive this? I've tried several ways to do this but wasn't successful. This is the error I get, where 'Hello' and 'World' are the arguments I'm passing -
Error: Unable to access jarfile jarfile.jar Hello World
Useful links: How to get java output with ruby