How to require a straight '.class' file

I’m familiar with how to require jar files, but I can’t seem to quite be
able to figure out how to reference a class like this:

Dir[’**/*.class’]
=>
[“target/classes/org/familysearch/digitalarchive/tapeingestreader/Boolean2.class”]

no incantation of $: and java_import seem to work.

Is this possible currently (require a straight .class file)?

Thanks.
-r

On Sep 8, 2010, at 10:09 PM, Roger P. wrote:

I’m familiar with how to require jar files, but I can’t seem to quite be
able to figure out how to reference a class like this:

Hi Roger - I struggled with this for a while as well. This is what
works for me.

Let’s say I have ‘myclass.class’ which has a class called ‘myclass’ in
‘mypackage.myclass’. This causes two problems because JRuby doesn’t
like non-Camelcased classes (because Modules have to have cap-Alpha
starts I think).

First, create a directory (under lib/ for example - though not
necessary) called mypackage and put myclass.class in there.

Then this should work:

require ‘java’
$CLASSPATH << ‘lib’

myclass = JavaUtilities.get_proxy_class(‘mypackage.myclass’)

@myclass = myclass.new

Regards,
David

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

require ‘java’
$CLASSPATH << ‘lib’

myclass = JavaUtilities.get_proxy_class(‘mypackage.myclass’)

Many thanks.
The following seems to work:

$CLASSPATH<<‘target/classes’
=>
[“file:/C:/dev/digitalarchive_trunk/dax/tapeingestreader/target/classes/”]

import org.familysearch.digitalarchive.tapeingestreader.Boolean2

(where file
“target/classes/org/familysearch/digitalarchive/tapeingestreader/Boolean2.class”
exists)

It surprised me that (it appears) that $LOAD_PATH is searched for jar
files but not for .class files (?)

I would have originally expected that doing the following would work:
$: << ‘target/classes’
java_import org.familysearch.digitalarchive.tapeingestreader.Boolean2

So…should I report this as a feature request? Or is it “the way it’s
supposed to be and going to be” already?

-r