Executing jrubyc generated classes with java.exe?

Hi,

I’d like to compile jruby programs in to java classes and then execute
these classes directy on the jvm. I can’t seem to get it to work. Wwhat
am I missing?

C:\Users\steve>type test.rb
require ‘java’

puts “hi steve”
C:\Users\steve>jruby test.rb
hi steve

C:\Users\steve>jrubyc test.rb
Compiling test.rb to class test

C:\Users\steve>java test
Exception in thread “main” java.lang.NoClassDefFoundError:
org/jruby/ast/executa
ble/AbstractScript
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Caused by: java.lang.ClassNotFoundException:
org.jruby.ast.executable.AbstractSc
ript
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
… 12 more
Could not find the main class: test. Program will exit.

Are the required jar(s) on the classpath?

windoze:
java -cp .;%JRUBY_HOME%\lib\jruby.jar test.rb

linux / os-x:
java -cp .:$JRUBY_HOME/lib/jruby.jar test.rb

2011/4/14 Gary W. [email protected]

Thanks. Both of you were right on target. Adding the jruby.jar to the
classpath was needed:

C:\Users\steve>set CLASSPATH=C:\jruby-1.6.0\lib\jruby.jar;%CLASSPATH%

C:\Users\steve>set classpath
CLASSPATH=C:\jruby-1.6.0\lib\jruby.jar;.;C:\Program Files
(x86)\jtidy-r938\jtidy-r938.jar;C:\Program Files
(x86)\xerces-2_9_0\resolver.jar;C:\Program Files (x86
)\xerces-2_9_0\serializer.jar;C:\Program Files
(x86)\xerces-2_9_0\xercesImpl.jar;C:\Program Files
(x86)\xerces-2_9_0\XercesSamples.jar;C:\Program Files
(x86)\xerces-2_9_0\xml-apis.jar;C:\Program Files
(x86)\Java\jre6\lib\ext\QTJava.zip

C:\Users\steve>java test
hi steve