Forum: Ruby Problem executing example code from XRuby (was Re: where to

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jesús Gabriel y Galán (Guest)
on 2007-06-21 18:57
(Received via mailing list)
On 6/21/07, Axel E. <removed_email_address@domain.invalid> wrote:

> It sounds to me that you get this error because you expect
> Ruby to behave like Java ... right?
> If so, could you help me on a Ruby/Java problem for which
> I got no response so far ?

> I am experiencing problems while executing the example
> script from xruby,
> I am going through the example at

> axel@dhcppc1:~> java -jar test.jar
> Exception in thread "main" java.lang.NoClassDefFoundError: 

Hi Axel,

I haven't tested anything but a quick glance at the explanation in the
wiki and looking at the error it seems that you need something else in
the classpath apart from your test.jar. When you run java with the
-jar option, your classpath (the list of directories and jars where
java looks for classes) is limited to the file you specify. Also with
that option, java checks the jar file for a manifest specifying the
main class (the class that contains a main method to execute). From
the wiki, it seems that your generated class implements an interface
called RubyProgram, and from the error it seems that it's located in
package com/xruby/runtime/lang/RubyProgram. So I suggest locating this
RubyProgram interface definition, may inside the xruby-0.1.4.jar (jar
tvf xruby-0.1.4.jar| grep RubyProgram), and if it's there try running
your program as:

java -cp xruby-0.1.4.jar:test.jar test.main

(I see from the wiki that the test.jar should contain a class main in
the test package which contains the main method, so the above should
work). You can also specify the classpath as a environment variable

I haven't tested anything, I just looked at the information in the
wiki, hope this helps.

Axel E. (Guest)
on 2007-06-24 18:26
(Received via mailing list)
Thank you very much,
Jesús !This worked very well!

Best regards,

This topic is locked and can not be replied to.