Invoking Java From Ruby

I did this using the rubygem Java-Ruby-Bridge. I did this because I was having problems with JRuby and wanted to execute my class from within Ruby.

Here is a simple way to do it, as long as you remember the classpath.

require 'rjb'
Rjb::load(classpath = '../../TestJava/bin', jvmargs=[])
test = Rjb::import('Test')
c = test.new
c.foo3

This way I was able to invoke a web camera testing program written in java with a few environment variable calls

ENV['CLASSPATH'] = '../../JavaRobots/dist/javarobots.jar;../../JavaRobotsLib/jai_core.jar;../../JavaRobotsLib/jai_codec.jar'require 'rjb'test = Rjb::import('com.scottpreston.javarobot.vision.ImageViewer')
c = test.new("c:\\temp\\fcover.jpg")
#default_close_operation = JFRAME::EXIT_ON_CLOSE
sleep 5