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

**URL:** <https://www.ruby-forum.com/t/problem-executing-example-code-from-xruby-was-re-where-to/107413>\
**Category:** Ruby\
**Created:** [June 21, 2007, 4:57pm UTC](https://www.ruby-forum.com/t/problem-executing-example-code-from-xruby-was-re-where-to/107413 "2007-06-21T16:57:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JesSSSSs\_Gabriel\_y\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4da419/32.png) [@JesSSSSs\_Gabriel\_y\_S](https://www.ruby-forum.com/u/JesSSSSs_Gabriel_y_S)\
**Post date:** [June 21, 2007, 4:57pm UTC](https://www.ruby-forum.com/t/problem-executing-example-code-from-xruby-was-re-where-to/107413/1 "2007-06-21T16:57:43Z")

</div>

On 6/21/07, Axel E. [removed\_email\_address@domain.invalid](mailto: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](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](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.

---

<div class="post-metadata">

**Author:** ![JesSSSSs\_Gabriel\_y\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4da419/32.png) [@JesSSSSs\_Gabriel\_y\_S](https://www.ruby-forum.com/u/JesSSSSs_Gabriel_y_S)\
**Post date:** [June 24, 2007, 4:26pm UTC](https://www.ruby-forum.com/t/problem-executing-example-code-from-xruby-was-re-where-to/107413/2 "2007-06-24T16:26:10Z")

</div>

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

Best regards,

Axel
