Using classes from jar depending on classes from different jar

Hello,

I have the following problem. Say I have two Java classes, Foo and Bar,
where Bar depends on Foo (it contains private static Foo foo = new
Foo();). Each of these classes (they are from the same package “p” but
that’s not important) is in a different jar (foo.jar and bar.jar). Now
I’d like to require both jars from JRuby code and then use the Bar
class, only it doesn’t seem to work. This is what happens in jirb:

irb(main):001:0> require “foo.jar”
=> true
irb(main):002:0> Java::p.Foo
=> Java::P::Foo

So far, so good.

irb(main):003:0> require “bar.jar”
=> true
irb(main):004:0> Java::p.Bar
NameError: cannot link Java class p.Bar, probable missing dependency:
p/Foo
from
/opt/jruby/lib/ruby/site_ruby/shared/builtin/javasupport/java.rb:51:in
`method_missing’
from (irb):4

How do I get Bar class aware of the Foo class? I can’t start jruby with
-classpath parameter, I need to be able to require jars dynamically from
JRuby code. Is that possible?

Ondřej Kučera


Cheers,
Ondřej Kučera


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hello,

On 07/22/10 17:05, Ondřej Kučera wrote:

=> true
/opt/jruby/lib/ruby/site_ruby/shared/builtin/javasupport/java.rb:51:in
`method_missing’
from (irb):4

How do I get Bar class aware of the Foo class? I can’t start jruby with
-classpath parameter, I need to be able to require jars dynamically from
JRuby code. Is that possible?

I take my question back. It actually does work OK, as long as there’s no
“p” subdirectory in the directory from which jirb was run. Because if
there is such directory, JRuby tries to find class Foo there and if it
doesn’t, it doesn’t look into foo.jar for it. Or at least that’s what
I’ve figured from my experiments so far.

Ondřej Kučera


Cheers,
Ondřej Kučera


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs