JRuby on Java ME


#1

Another one several of you have asked about…JRuby running on Java ME:

This is using Sun’s reference implementation “cvm” with the CDC
(Connected Device Configuration) and the PBP (Personal Basis Profile)
set of classes. It’s basically the same as what you’d have on a Java
ME-enabled phone or embedded device supporting the same level of APIs.

PBP is available here, for Linux only. I’m not sure whether it’s been
open-sourced yet or not, but I thought it was planned:

http://java.sun.com/javame/downloads/index.jsp

The project is hosted here:

It’s essentially JRuby 1.2 forked and stripped of libraries and code
that aren’t supported in CDC. My intention with this is to get it
running with a base set of Ruby classes but with Java integration still
functional. That will allow most basic Ruby scripts to work while
providing access to the rest of the Java APIs for bits I had to rip out.

It’s only running interpreted right now, just like the Android version
of JRuby, but as in that case I expect most people would want to
precompile Ruby code and ship it all as one unit.

I think there are many other possible ways we could repurpose JRuby like
this; it really only took me a couple days of trimming to get this far.
Android will take far less time, and other “mini ruby” profiles might be
possible for other platforms as well.

Questions, comments, patches welcome :slight_smile:

  • Charlie

#2

Hi Charlie,

That’s great news! I was wondering about this again since I saw the
post about JRuby on Android. I’ve been trying to figure out the best
way to get Ruby on my Windows mobile phone so I could do some quick
scripting without needing to go through the compile process for either
J2ME or WinMobile/.NET CF, because I don’t have those set up at the
moment.

Looks like this may be just the thing I need to test a couple of things.

Cheers,

ast


#3

Charles Oliver N. wrote:

open-sourced yet or not, but I thought it was planned:
still functional. That will allow most basic Ruby scripts to work
profiles might be possible for other platforms as well.

Questions, comments, patches welcome :slight_smile:

  • Charlie

This would be awesome!


#4

From: “Charles Oliver N.” removed_email_address@domain.invalid

I think there are many other possible ways we could repurpose JRuby like
this; it really only took me a couple days of trimming to get this far.
Android will take far less time, and other “mini ruby” profiles might be
possible for other platforms as well.

This idea of a stripped-down JRuby running precompiled Ruby code,
still able to access Java APIs sounds ideal for applets.

Do you think it would be a lot of work to target one of these “mini
rubys”
for applets?

This gentleman currently has an OpenGL / JRuby applet proof of
concept – but has he points out, the complete JRuby jar is large
and implies a lengthy download:

http://sikanrong.com/blog/jruby_applet__opengl_running_from_ruby_in_an_applet

I think it would be awesome to have a compact JRuby runtime for
use in applets. I don’t see requiring the ruby code to be precompiled
to be a problem at all. (Perhaps even a benefit.)

Regards,

Bill


#5

Bill K. wrote:

This idea of a stripped-down JRuby running precompiled Ruby code,
still able to access Java APIs sounds ideal for applets.

Do you think it would be a lot of work to target one of these “mini rubys”
for applets?

Yes, and I have applets firmly in mind as I start thinking about
modularizing/stripping/shrinking JRuby. Applets are a little less
restrictive than either JavaME or Android, since we’ll have a “full”
Java impl, but we still need to make things more modular and make it
easier to ship only what you need. I suspect the same logic will apply
equally to applet and Android deployments (jruby-cdc is a separate fork
for JavaME that will live a life of its own).

  • Charlie

#6

Bill,

What would be the “sweet spot” for applets?

I acknowledge my prejudice, reluctantly accepting that memories of
ancient rants about “craplets” are not just a bad dream.

Peter B.
(917) 445 5663 removed_email_address@domain.invalid


#7

On Thu, Mar 5, 2009 at 9:23 PM, Bill K. removed_email_address@domain.invalid wrote:

Simple 3D example (gears demo)
https://jogl-demos.dev.java.net/applettest.html

glxgears in an applet!

It’s all bugged out though, at least in Firefox/Mac. When I switch tabs
the
gears are still there… and even though it claims the applet doesn’t
need
to be signed I get a warning saying the signing certificate is invalid
and
asking if I want to make an exception.


#8

From: “Tony A.” removed_email_address@domain.invalid

gears are still there… and even though it claims the applet doesn’t need
to be signed I get a warning saying the signing certificate is invalid and
asking if I want to make an exception.

Hmm… I’m seeing the same thing on Firefox/Mac. :frowning:

It works fine for me on Firefox/Windows and (surprisingly)
IE6/Windows.

It works OK for me on Safari/Mac (it does ask if I want
to trust the applet, but it says the cert is valid.)

No tab problems on Safari/Mac or Firefox/Windows… but,
I get the tab switching issue you described on Firefox/Mac.

Sigh… always something.

(I tried submitting a bug to Sun, but they only accept
Java bugs for Windows/Linux/Solaris. Submitted to Apple
instead.)

Regards,

Bill


#9

Bill K. wrote:

(I tried submitting a bug to Sun, but they only accept
Java bugs for Windows/Linux/Solaris. Submitted to Apple
instead.)

FWIW, the JavaFX guys sound hopeful that Apple will release Java updates
including the many improvements Sun’s made for JavaFX. This will
obviously help JavaFX, but also could greatly improve graphics
performance and startup speed of applets in general.

I hope they’re right. People keep telling me JavaFX and/or applets are
superfast on recent Windows Java 6 releases.

  • Charlie

#10

Bill K. wrote:

But – of course – I’d much rather code an app like
this in Ruby, than Java… :slight_smile:

Consider Clojure.


#11

Peter,

From: “Peter B.” removed_email_address@domain.invalid

What would be the “sweet spot” for applets?

I acknowledge my prejudice, reluctantly accepting that memories of
ancient rants about “craplets” are not just a bad dream.

For me, I’m interested in hardware accelerated 2D and 3D
graphics.

Although I’m impressed with what people are accomplishing
with dynamic HTML and JavaScript these days, most of the
best web applications still feel clunky to me.

Recently, it has become possible to write applets that
make use of both 2D and 3D hardware accelerated graphics,
which run in modern browers on windows, linux, and OS X.

2D example:
https://jdk6.dev.java.net/Java2DApplet.html

Simple 3D example (gears demo)
https://jogl-demos.dev.java.net/applettest.html

The following is a nice example mixing 2D rendering into
3D textures. (It is not packaged as an applet, but, it
could be!)
http://weblogs.java.net/blog/campbell/archive/2007/01/java_2d_and_jog.html

Finally, an older demo, nothing too special graphically,
but showing some of the GUI widgets available to applets:
http://java.sun.com/products/plugin/1.4.1/demos/jfc/SwingSet2/SwingSet2.html

Also - it’s also now possible to actually drag and drop
files from your desktop, onto an applet!

For that to work the applet binary has to be signed, and
the user has to click OK at a prompt allowing the applet
to run. But still… real drag & drop from the desktop
into a web app has nice possibilities:
http://www.radinks.com/upload/applet.php

My feeling is, the above technologies could be combined
in a way that could result in a pretty formidable web
application. (Also, note, while the above tend to show
fixed size applets, one only need place the applet in
a variable width div (e.g. width=“80%” or whatever) and
the applets resize just fine along with the browser
window.)

But – of course – I’d much rather code an app like
this in Ruby, than Java… :slight_smile:

Thus my excitement at the possibility of having a mini
version of JRuby for applets.

Regards,

Bill