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


#1

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 ?

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/256316

I am experiencing problems while executing the example
script from xruby,
I am going through the example at
http://code.google.com/p/xruby/wiki/XRubyHackingGuide

axel@dhcppc1:~> java -jar test.jar
Exception in thread “main” java.lang.NoClassDefFoundError: com/xruby/runtime/lang/RubyProgram

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
$CLASSPATH

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

Jesus.


#2

Thank you very much,
Jesús !This worked very well!

Best regards,

Axel