Hi everybody,
I am trying to import some java class in order to use its methods.
The java class code is like the following (capital letters are written
like this):
public class SetNMOAndVKHF{
//First method (name begins with Capital letter)
public static void AddVKHF(Object param1, boolean params2)
throws IOException, Exception{
//The method instructions
…
}
//second method
private static void setTest(Type1 var1, Type2 var2) {
//Instructions
…
}
}
I want to import that class in my class called “MyClass” in JRuby
My Jruby code is the following:
include Java
java_import java.lang.System
java_import java.lang.Object
$CLASSPATH << “#{RAILS_ROOT}/lib/myfolder”
java_import com.folder1.folder2.SetNMOAndVKHF
Dir["#{RAILS_ROOT}/lib/jars/compatibles/*.jar"].each {|jar| require jar}
//MyClass is in The Rails app/models directory
class MyClass
def initialize()
end
def testme
…
SetNMOAndVKHF.AddVKHF(param1, param2)
…
end
end
Then i am calling “MyClass” in some controller like this
test = MyClass.new
test.testme
But while executing i am getting the following error:
"SetNMOAndVKHF(ArgumentError) A copy of MyClass has been removed from
the module tree but is still active!
Before that got this error "Java package com.folder1.folder2 does not
have a method const_get() "
In debug mode, those errors happen at the beginning, on the first line
of MyClass (before the line calling my java class method).
So my question is how can i import the Java class “SetNMOAndVKHF”, then
use its “AddVKHF” method (with particularity method name begins with
Capital letter).
Can someone explains me how to avoid these errors.
Thanks in advance for your help.