Hi,

 

I’m currently looking for a way to get a python script running on an Java ME (IMP/CLDC) environment. I actually already ported PyMite to Java but it was to slow because it was interpreting Python byte code at runtime.

 

Then I though Clamp could be the solution and Charlie Groves pointed me back to jython which is able to compile Python scripts to class files.

 

I used the compileall script to compile a midlet written in python, something like this:

from javax.microedition.midlet import MIDlet

class PyMidlet(MIDlet):

                def __init__(self):

                               print "Midlet Constructor"         

                def startApp(self):

                               print "Application started."                       

                def pauseApp(self):

                               print "Application paused."                       

                def destroyApp(self, cond):

                               print "Application destroyed, condition=", cond

 

I packaged this as a jar, created a jad and run it with the WTK emulator. It says not Midlet “PyMidlet” found. Then I used JBE to look at the generated java bytecode and compared it to the bytecode of a “real” Java midlet.

 

Taking a quick look, I saw two important things:

1.)    It implements the PyRunnable interface instead of MIDlet

2.)    All method got a $1, $2 attached to its names.

 

So, now the question, is it possible, to create a class file that looks and behaves like a “real” MIDlet from other java classes?

 

Ok, and the second, maybe more important, question is, is “only” the python libraries implemented in Java that use advanced java features (HashMap e.g.)  that do not exist in JavaME? That would be Ok, because I’m a pro in porting JavaSE code to JavaME. Or, does the core part, that is essentially necessary to run even the most simple python script, does use e.g. class loading which can not be implemented in Java ME at all?

 

What I need is a self-contained jar file including only the necessary class files. I don’t need the interpreter and features like the interactive input.

 

So, I am willing to spend some time (days, weeks) to the necessary work to get it running on Java ME. But if there is some general restrictions in the architecture of Jython, it won’t be possible.

 

Any comments are welcome!

 

Jan