I have created a gem on my local system for text mining which relies on
external Java libraries for classification tasks. I'm trying to harness
the power of Java through JRuby here. Directory structure is as follows:

```
- classifier/
 * classifier.gemspec
 * Gemfile
 * Gemfile.lock
 * lib/
     * classifier/
         * version.rb
         * sample_classifier.rb
     * classifier.rb
     * java/
         * sample_lib.jar
         * another_sample_lib.jar
         * yet_another_sample_lib.jar
 * Rakefile

```

I'm loading these jars in `lib/classifier.rb` as

```
Dir["java/*.jar"].each{|jar| require jar}

```

I have added this gem to a Git repository and referenced it in the
Gemfile of my Rails 3.0.9 project. However, my sample\_classifier.rb
fails to locate any classes 'import'ed from any of the jars under
`lib/java`.

Things work if I copy `lib/java` to my Rails application 

```
lib/ directory

```

and add the following in `sample_classifier.rb`:

```
Dir["lib/java/*.jar"].each{|jar| require jar}

```

However, I don't think it's a good practice to spill the gem's
dependencies in my Rails app. Is there a better way to achieve this? I
looked around for bundling jar files with a gem but I found results for
exactly the opposite i.e. bundling gems within a jar file. Can I add
these jars to Rails' config.autoload\_path or similar to load them when
the application starts? Is it a good practice to bundle jar dependencies
with the gem?

I'm sure there's a cleaner way to do this.