Search code examples
javarubyrubygemsjruby

Java commands in JRuby


I am adding jar files to my jruby code in the .rb file

I put the following:

import 'java'
import 'weather.jar'
import 'weatherStatus.WeatherStatus' #this is the package and class

Now I have classes in weather.jar that I need to use here but it keeps giving me errors. I don't know how to convert the following java lines to jruby and everytime I try something from the tutorials, it give me errors.

The following command lines are from java and I want to include them in my jruby file:

sunnyDay var1 = null;
var1 = new sunnyDay(var2, var3);
String var4 = var1.TimeOfDay(var5);

sunnyDay is from package called weatherStatus

How can I do that in Jruby?


Solution

  • I suggest you thoroughly read the following two links to have a better understanding of using JRuby :)

    https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby

    https://github.com/jruby/jruby/wiki/DirectJRubyEmbedding