On Tue, Mar 16, 2010 at 10:39 AM, Ahmed Ragab Nabhan <anab...@uvm.edu> wrote:
> I have used the simple utility jrubyc that compiles a .rb file into .java.
> When I try to
> run the resulting .class file, I got got an exception:
> $ jrubyc --java myruby.rb
> javac -d /Users/anabhan/Work/Workspace/JavaRuby -cp
> /Users/anabhan/.rvm/rubies/jruby-head/lib/jruby.jar:. MyRubyClass.java
>
> $ java  -cp /.rvm/rubies/jruby-head/lib/jruby.jar:.  MyRubyClass
>
> Exception in thread "main" java.lang.ExceptionInInitializerError
> Caused by: java.lang.NullPointerException
>        at MyRubyClass.<clinit>(MyRubyClass.java:18)

I replied to your other email about this issue...and then found that I
still had a bug. I've fixed that now (in r12816f3)

We should probably file a bug to provide a better error message when
the class can't be found. Maybe you could do that?

You should also know that your MyRubyClass in myruby.rb does not
define a "main" Java method, so you'll get an error like this:

~/projects/jruby ➔ java -cp .:lib/jruby.jar MyRubyClass
Exception in thread "main" java.lang.NoSuchMethodError: main

If you define a main method like so:

require 'java'
class MyRubyClass
 java_signature "void main(String[])"
 def self.main(args)
   MyRubyClass.new.helloWorld
 end

 def helloWorld
   puts "Hello from Ruby"
 end
end

It should work fine:

~/projects/jruby ➔ java -cp .:lib/jruby.jar MyRubyClass
Hello from Ruby

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to