Forum: JRuby Another classpath problem !

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Arnaud G. (Guest)
on 2009-02-04 19:57
(Received via mailing list)
Hello list,

I don't know why but I still have a class not found since I do:

Dir["lib/**/*.jar"].each do |jar|
  require jar
end
I also try with the full path since in the jruby cookbook it seems
that jruby use the working directory not the current file....

Dir["lib/**/*.jar"].each do |jar|
  require File.expand_path(jar)
  puts "jar file =#{File.expand_path(jar)}"
end

I found some thread about using a $CLASSPATH and << jar inside ....
without success ...

I know it is a newbie question but I if someone can help me....

thanks

arnaud

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Nick S. (Guest)
on 2009-02-04 21:55
(Received via mailing list)
On Wed, Feb 4, 2009 at 11:56 AM, Arnaud G. 
<removed_email_address@domain.invalid>
wrote:
> Dir["lib/**/*.jar"].each do |jar|
>  require File.expand_path(jar)
>  puts "jar file =#{File.expand_path(jar)}"
> end
>
> I found some thread about using a $CLASSPATH and << jar inside ....
> without success ...
>
> I know it is a newbie question but I if someone can help me....

Are you certain you have all the jars you need? If a java jar relies
on classes in other dependent jars and those are not present, you'll
still get a ClassNotFoundException as the JVM tries to resolve all
references when the class(es) is/are loaded.

Just a thought,
/Nick

>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Arnaud G. (Guest)
on 2009-02-05 08:26
(Received via mailing list)
thanks for answer I will double check....
But this is the good way to add jar, there is not other variable to
set or something else.....

arnaud

2009/2/4 Nick S. <removed_email_address@domain.invalid>:
>>
> Are you certain you have all the jars you need? If a java jar relies
>> arnaud
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Arnaud G. (Guest)
on 2009-02-05 22:05
(Received via mailing list)
Well, after lot of investigation it seems that the problem is when a
class try to access a jar file....
Finally, I decided to create another jar file for my class and it
works... but I still don't understand why it is not working since the
jar is correctly require and import and the class are in the ruby
path....

arnaud

2009/2/4 Arnaud G. <removed_email_address@domain.invalid>:
> Dir["lib/**/*.jar"].each do |jar|
>
> arnaud
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Charles Oliver N. (Guest)
on 2009-02-06 01:45
(Received via mailing list)
The problem may be with how classpaths are organized. If you have
something on the system classpath (like through env var) and then try to
load jar files, the env-var-classpath class won't see those jars. The
jar files loaded at runtime live at a deeper classloader level. The way
to avoid this is to load everything at runtime through JRuby.

Does that fit your circumstance?

Arnaud G. wrote:
>> Hello list,
>>  require File.expand_path(jar)
>> arnaud
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Arnaud G. (Guest)
on 2009-02-06 21:48
(Received via mailing list)
I thought about this, but I have no sytem classpath in my env.... But
using this strategy (setting the classpath env and add jar files and
java classes folder) works before launching jruby....

But I thought that using require 'myjarfile' add the jar file to the
java classpath and since my classes were at the same level of my ruby
file was enough.... (I also try to add the . level to $LOAD_PATH using
__FILE__ ..., because it seems that there is a difference bettween the
working directory and the current ruby file... anyway $LOAD_PATH seems
different to the java classpath)

->But if you talk about classloading I would like to know if you have
a minute the hierachy of jruby classloading strategy ? I am a bit lost
beetwen java classpath env, $LOAD_PATH, using require and so on....

->And if you have another minute ;-), can you please tell me how to
load everything a jruby runtime ... I mean adding a folder and not the
jar files since I thought it is just done with require 'my path to a
jar file'

thanks
arnaud



2009/2/6 Charles Oliver N. <removed_email_address@domain.invalid>:
>> Well, after lot of investigation it seems that the problem is when a
>>> Hello list,
>>>  require File.expand_path(jar)
>>> arnaud
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.