Hi,
I have a jruby class which implements a java interface and I want to
call it from Java.
JavaInterfaceExample.java:
interface JavaInterfaceExample{
void add(int a, int b);
}
JrubyAdderImpl.rb
require ‘java’
require ‘JavaInterfaceExample’
class JrubyAdderImpl
include JavaInterfaceExample
def add(a, b)
a+b
end
end
JavaCallerApp.java
class JavaCallerApp {
public static void main(String[] args) {
JrubyAdderImpl jrubyClass = new JrubyAdderImpl();
System.out.println(“Adding 3+5=” + jrubyClass.add(3,5)); //
Display the string.
}
}
I compiled each class but the java caller class can’t find the method
implemented in Jruby:
$javac JavaInterfaceExample.java
$jrubyc JrubyAdderImpl.rb
$javac -cp /usr/local/jruby/lib/jruby.jar:. JavaCallerApp.java
JavaCallerApp.java:5: cannot find symbol
symbol : method add(int,int)
location: class JrubyAdderImpl
System.out.println(“Adding 3+5=” + jrubyClass.add(3,5)); //
Display the string.
^
1 error
Is this possible in JRuby? or does the dynamic typing get in the way?
–
@tommychheng
Programmer and UC Irvine Graduate Student
Find a great grad school based on research interests:
http://gradschoolnow.com
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email