Not able to load my custom java classes in JRuby

587 Views Asked by At

I have created one java project. Folder structure is like

Test
  - src
      -TestJavaCall.java

I created jar of this prject test.jar.

Code in my ruby file is as follows.

include Java
require '/home/office/test.jar'
java_import Java::TestJavaCall

 testJava = TestJavaCall.new

When i am executing this script, i am getting this error.

NameError: cannot link Java class TestJavaCall
  get_top_level_proxy_or_package at org/jruby/javasupport/JavaUtilities.java:49
                   const_missing at file:/home/spaul/.rvm/rubies/jruby-1.7.4/lib/jruby.jar!/jruby/java/java_module.rb:4

Please let me know what is the way to use custom java classes in ruby?

Source code of TestJavaCall.java

public class TestJavaCall {

    public void testJavaCall()
    {
        System.out.println("test java call");
    }
}
0

There are 0 best solutions below