Tuesday, February 24, 2009

Domo Arigato, Mr. Ruboto

# cat test.rb
require 'java'
import java.lang.System

class Ruboto
def greet(who)
puts "Hello, #{who}!"
end
end

name = System.get_property('java.runtime.name')
Ruboto.new.greet(name)

# dalvikvm -classpath ruboto.jar org.jruby.Main -X-C test.rb
Hello, Android Runtime!




Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 2.5 Attribution License.

21 comments:

Hasham Malik said...

so Jruby comes to android platform thats wonderful :)

khelll said...

That's amazing!

Dag Fjeld Edvardsen said...

Wow, that is so insanely cool!

Thiago Pradi said...

Awesome!

Anonymous said...

newbie question:
does this mean that jruby can be used to develop applications on the android plattform?

Psycho said...

Last week I fought with CRuby to cross-compile miniruby for Android. Damn, should have waited a week :-) Thank you for the effort. When/where do we get more details?

Marc Seeger said...

uh, me likey!

Hannes Wallnoefer said...

Your posting tempted me to try the same for Rhino - and it worked! Thanks a lot!

James Britt said...

Charlie, you rule.

Jared said...

I guess last night's RUM inspired you.

joakime said...

so ... where is Project Ruboto hosted so that we all may participate in the fun?

remi said...

mmm, I can't wait to play! Code?

Ethan said...

That's pretty cool. Now I want to get an Android phone.

Marcelo said...

yay!

source?

mnjsmart said...

Wow. Now that the fastest turn around I have ever seen. Very cool Charlie. Sweet!

Robert Dober said...

Just great...

Mark Murphy said...

Hey, if you need any particular help with Android support in JRuby, drop me a line. I was planning on doing Android/JRuby experiments in a couple of months, but if you're starting sooner, that's cool too!

Roger Pack said...

looks like MRI [can] run on android.
http://otype.net/2009/01/static-ruby-miniruby-187-on-android-dev-phone-1/

?
-=r

Anonymous said...

I thought that JRuby does quite a bit of dynamic Java byte code generation, and that Dalvik doesn't support dynamic byte code generation. Am I wrong on one of those two points? Would you mind giving a brief description of how you've gotten a dynamic language working on Dalvik? Thanks, and exciting work!

Roger Pack said...

appears that it disables its just in time compilation http://www.infoq.com/news/2009/02/jruby12rc1-android-support

verborghs said...

I just succeeded in running jruby code from an 'Activity'. the android SDK generates a R class with static inner classes that have lower case names and again there own static fields eg in java R.layout.main (layout being the static class). this seems to create problems. Also code like this:

btn = $activity.find_view_by_id(0x7f050000)
txt = $activity.find_view_by_id(0x7f050001)

class RunScriptListener
include View::OnClickListener

def onClick(view)
src = txt.text.to_s
eval(src)
end

end

btn.on_click_listener = RunScriptListener.new


seems to create the same problem with classloading: Exception: java.lang.UnsupportedOperationException: can't load this type of class file.
But of course you can't pass arguments to an activity for the davlikvm.