# Problems executing example code from xruby

**URL:** <https://www.ruby-forum.com/t/problems-executing-example-code-from-xruby/107378>\
**Category:** Ruby\
**Created:** [June 21, 2007, 12:42am UTC](https://www.ruby-forum.com/t/problems-executing-example-code-from-xruby/107378 "2007-06-21T00:42:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Axel\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7c8e57/32.png) [@Axel\_E](https://www.ruby-forum.com/u/Axel_E)\
**Post date:** [June 21, 2007, 12:42am UTC](https://www.ruby-forum.com/t/problems-executing-example-code-from-xruby/107378/1 "2007-06-21T00:42:55Z")

</div>

Dear all,

I am experiencing problems while executing the example  
script from xruby, which should generate Java \*class  
code from ruby \*rb scripts.  
So the error I am getting requires some Java,  
and xruby rather than ruby knowledge.

I am going through the example at

[http://code.google.com/p/xruby/wiki/XRubyHackingGuide](http://code.google.com/p/xruby/wiki/XRubyHackingGuide),  
and I get the error below.

From the little Java I know so far, I suspect  
that this error is due to java not finding the class  
file that xruby generates. Is this true? Where are they  
stored – inside a \*jar file ? How do I tell java where they are?

Thank you very much.

Best regards,

Axel

axel@dhcppc1:~\> java -jar test.jar  
Exception in thread “main” java.lang.NoClassDefFoundError:  
com/xruby/runtime/lang/RubyProgram  
at java.lang.ClassLoader.defineClass1(Native Method)  
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)  
at  
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)  
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)  
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)  
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)  
at java.security.AccessController.doPrivileged(Native Method)  
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)  
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)  
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)  
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)  
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

---

<div class="post-metadata">

**Author:** ![Axel\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7c8e57/32.png) [@Axel\_E](https://www.ruby-forum.com/u/Axel_E)\
**Post date:** [June 21, 2007, 2:01pm UTC](https://www.ruby-forum.com/t/problems-executing-example-code-from-xruby/107378/2 "2007-06-21T14:01:06Z")

</div>

On 6/20/07, Axel E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> axel@dhcppc1:~\> java -jar test.jar  
> Exception in thread “main” java.lang.NoClassDefFoundError: com/xruby/runtime/lang/RubyProgram  
> at java.lang.ClassLoader.defineClass1(Native Method)  
> …

Haven’t used xruby myself but com.xruby.runtime.lang.RubyProgram  
seems from xruby and not from the generated code. Maybe you need xruby  
in your classpath? Putting the needed jars on the environment variable  
CLASSPATH or using java -classpath argument might help. Try something  
like ‘java -classpath /path/to/xruby.jar -jar test.jar’

You can read  
[http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html](http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html)  
or [Setting the class path](http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html)  
for more information on how to set up the classpath.
