I have been programming for a while with Ruby and I really enjoy it. Lately I started having the need of compiling some ruby code. For several reasons using Ruby2exe is not an option for me. So I decided to give Jruby a try (generating a jar would be good enough).
I am using windows and I installed java JDK 6u17 (at C:\Program Files\Java\jdk1.6.0_17).
I installed jruby 1.4 at C:\jruby
I created a hello world in java, compile and executed it just fine (so java works fine).
I created a file "script.rb" with:
puts "Hello, world"
I run this program with jruby:
jruby script.rb
And it works fine.
I did set JAVA_HOME to C:\Program Files\Java\jdk1.6.0_17
I also successfully run:
java -jar c:\jruby\lib\jruby.jar script.rb
I then compile with the command:
jruby -S jrubyc script.rb
It generates the class 'script.class'
My problem is that I found no way to properly execute script.class
I try:
java -cp .:c:\jruby\lib\jruby.jar script
And I get the error message:
Exception in thread "main" java.lang.NoClassDefFoundError: script
Caused by: java.lang.ClassNotFoundException: script
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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: script. Program will exit.
I also tried copying jruby-complete-1.4.0.jar to local dir as well as several other options.
Anyone know what am I doing wrong?