Search code examples
amazon-web-servicesjrubyaws-sdkjrubyonrails

using aws sdk for java in Jruby


I have an app which uses the amazon web services.The app is installed with jruby on rails.I have to use java aws sdk for calling amazon web services.

Can u help me as in how to include aws sdk in my app and use it

Thanx in advance


Solution

  • You will want to put the jar files for the sdk inside your /lib/java folder, and make sure to include them in your classpath. (See this example on including a JDBC driver, same concept.)

    Then to use the objects in Ruby you just instantiate them like you normally would:

    require 'java'
    
    myAwsObj = com.amazon.aws.class.someMethod('some','params')
    

    You can visit the JRuby Kenai site for examples of calling Java from inside Ruby. Obviously the package name above I made up, but you should get the idea from there. The Kenai page also has lots of other examples and gotchas.