How to Include Ruby Modules in Standalone Jar?

I recently put together a simple jruby script that I wrapped into a
standalone jar, which includes jruby.jar file. The script uses
‘net/http’
and ‘time’ modules and so I had to copy the ‘net/http’ and ‘time’ files
into the folder from which I created the jar. Rather than performing
this task manually are there any jruby tools/utilities that can automate
this process? Thanks.

-Dan

How much do you need to automate? From following Nick S.'s
gems-in-a-jar recipe (
JRuby 1.1.6: Gems-in-a-jar),
you only end up calling 3 or 4 lines to get it done for simple cases. I
haven’t had too many issues doing that and I’ve always just made a
simple
Rake task or .sh script to handle it for distribution.

-Nick K.

On Thu, May 12, 2011 at 7:07 AM, Mike L. [email protected] wrote:

I’ve had good success using warbler (HEAD)

At RubyConf 2010 Nick S. gave a presentation on using Warbler to
create standalone JRuby JARs:

Video is available here:
http://confreaks.net/videos/425-rubyconf2010-self-contained-source-free-executable-ruby-applications-with-warbler


Phillip G.

Though the folk I have met,
(Ah, how soon!) they forget
When I’ve moved on to some other place,
There may be one or two,
When I’ve played and passed through,
Who’ll remember my song or my face.

On May 11, 2011, at 8:10 PM, Dan K. wrote:

I recently put together a simple jruby script that I wrapped into a
standalone jar, which includes jruby.jar file. The script uses
‘net/http’
and ‘time’ modules and so I had to copy the ‘net/http’ and ‘time’ files
into the folder from which I created the jar. Rather than performing
this task manually are there any jruby tools/utilities that can automate
this process? Thanks.

-Dan

I’ve had good success using warbler (HEAD)

Mike

Yes, check out the Warbler 1.3.0 release.

http://caldersphere.rubyforge.org/warbler/

Specifically, you should be able to put your script in bin/ and any
libraries in lib/ and simply run ‘warble’ to get an executable jar file.

/Nick

Nick S. wrote in post #998277:

Yes, check out the Warbler 1.3.0 release.

http://caldersphere.rubyforge.org/warbler/

Specifically, you should be able to put your script in bin/ and any
libraries in lib/ and simply run ‘warble’ to get an executable jar file.

/Nick

I installed ‘warbler 1.3.0’ and did as instructed above; unfortunately,
running ‘warble’ simply froze the command prompt. I put my ruby source
code and the ‘launcher’ java file into bin and the ruby module files as
well as the contents of the jruby.jar file into the lib folder. Did I do
something wrong?

Also, rather than manually copying the ruby module files – ie.
‘net/http’, ‘time’, etc. – into the lib folder can warbler detect which
modules are required and copy/insert those files itself?

Thanks.

-Dan