On Thu, Mar 18, 2010 at 10:56 AM, Ahmed Ragab Nabhan <anab...@uvm.edu> wrote: > Hi Charlie, > > The main method defined in a ruby class is not generated properly by the > jrubyc utility. I mean the function has different signature than expected by > the JVM: > > public static Object main(Object args) > > while the JVM looks for a different signature: > > public static void main(String[] argv)
This is expected. If you specify no java_signature, it only provides Object for all the types, so main receives and returns Object. You need the java_signature line to tell jrubyc to give it that specific signature. require 'java' class Foo java_signature "void main(String[] args)" def self.main(args) args.each {|a| puts a} end end ~/projects/jruby ➔ jrubyc --java foo.rb Generating Java class Foo to Foo.java javac -d /Users/headius/projects/jruby -cp /Users/headius/projects/jruby/lib/jruby.jar:. Foo.java ~/projects/jruby ➔ java -cp .:lib/jruby.jar Foo hello goodbye hello goodbye You might also have an opinion on this question: should there be a mode that *just* generates the .java files? Right now the .java is being generated because it's a nice simple way to get Java classes out of jrubyc: we don't have to do dependency tracking, don't have to make sure the bytecode is exactly correct, and get free javac optimizations like multi-line string concatenations being condensed into a single string. However if you have a dependency on some other Java class, you may want to generate just the .java source and then compile all of your sources at once. We also need an ant task for this for the 1.5 release... - Charlie --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email