Help getting Ruby and Java to interact?
March 24, 2008 10:26 PM Subscribe
I'm trying to compile and run a Java class from Ruby, but I'm having some problems. I'm not very experienced with Ruby- please help me figure out what I'm doing wrong.
Basically what I'm trying to do is:
1. Inside a Ruby method, compile Foo.java (`javac Foo.java`)
2. Run Foo.class with arguments and save the 'console' output as a string. (result = `java Foo filename.txt`)
The command to compile Foo.java works, as Foo.class appears in the folder. However, part 2 doesn't seem to work as nothing prints when I try to print result (puts result). I'm probably doing something simple wrong but I'm not sure what it is as I'm basically picking Ruby up as I go without any actual grounding.