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.
E088bb5c80fd3c4fd02c2020cdacbaf0?d=identicon&s=25 Jesús Gabriel y Galán (Guest)
on 2007-06-21 16:57
(Received via mailing list)
On 6/21/07, Axel Etzold <> 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.

D0338c0de4cb3c5c17300396159933d1?d=identicon&s=25 Axel Etzold (Guest)
on 2007-06-24 16: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.