Hello, just started learning jRuby and tried to create a jar and use it but getting following error when I java_import 'packagename' NameError: cannot load Java class com.foo.bar. Could anyone point me in right direction. cat /Users/MacUser/jruby_projects/foo/bin/my_foo.rb java_package 'com.foo.bar' class Foo def bar(a, b) puts a + b end end ---- from foo folder I run warble jar then foo/foo.jar --- irb(main):001:0> require 'foo.jar' => true irb(main):004:0> $CLASSPATH => ["file:/Users/MacUser/.rbenv/versions/jruby-1.7.11/lib/ruby/shared/readline/jline-2.11.jar", "file:/Users/MacUser/.rbenv/versions/jruby-1.7.11/lib/ruby/shared/readline/readline.jar", "file:/Users/MacUser/jruby_projects/foo/foo.jar"] irb(main):003:0> java_import 'com.foo.bar' NameError: cannot load Java class com.foo.bar from org/jruby/javasupport/JavaClass.java:1250:in `for_name' from org/jruby/javasupport/JavaUtilities.java:34:in `get_proxy_class' from file:/Users/MacUser/.rbenv/versions/jruby-1.7.11/lib/jruby.jar!/jruby/java/core_ext/object.rb:26:in `java_import' from org/jruby/RubyArray.java:2409:in `map' from file:/Users/MacUser/.rbenv/versions/jruby-1.7.11/lib/jruby.jar!/jruby/java/core_ext/object.rb:22:in `java_import' from (irb):3:in `evaluate' from org/jruby/RubyKernel.java:1121:in `eval' from org/jruby/RubyKernel.java:1521:in `loop' from org/jruby/RubyKernel.java:1284:in `catch' from org/jruby/RubyKernel.java:1284:in `catch' from /Users/MacUser/.rbenv/versions/jruby-1.7.11/bin/irb:13:in `(root)' Thank you for your time.
on 2014-03-11 23:19
on 2014-03-12 09:39
just read the error: *NameError: cannot load Java class com.foo.bar* com.foo.bar.class is likely not in the package . treat java_import like Java's import - import classes not packages. for simple failures (esp. if you're getting started) may I advise to try out http://stackoverflow.com/questions/tagged/jruby K.
on 2014-03-15 12:25
Thank you !