Topic: Java for chumby!

I've posted some instructions for building a simple Java interpreter for chumby.

See this page for building JamVM to create a "Java dongle" that can be inserted into the USB port on the back to give the chumby Java support.

Re: Java for chumby!

any chance of this running straight on the chumby? rather than with a dongle?

is there support for two dongles? cos i wouldnt mind havin one for apps, other for swap/media space.

need upload space for the forums or a chumby blog? right here then
http://www.nophus.com/useru
username is chumby
password is chumby

Re: Java for chumby!

Well, the problem is that, while the Java VM is relatively small, the standard Java libraries, even compressed, take up around 9MB. That makes it prohibitively large.

Re: Java for chumby!

maybe you should ship chumby with an SD card slot or something. cos then people have the opportunity to upgrade if they need the extra space. SD cards cost peanuts nowadays. you can pick 128mb ones up for like £7

need upload space for the forums or a chumby blog? right here then
http://www.nophus.com/useru
username is chumby
password is chumby

Re: Java for chumby!

chedabob wrote:

maybe you should ship chumby with an SD card slot or something. cos then people have the opportunity to upgrade if they need the extra space. SD cards cost peanuts nowadays. you can pick 128mb ones up for like £7

Sure, but the socket and associated electronics adds to the overall cost of the chumby, and we already have a USB port that people can use to attach less expensive storage.

We *did* price it out and it was just too much.

6 (edited by carlynm 2007-01-25 15:50:02)

Re: Java for chumby!

Sooo... I put the .tgz on my dongle
Unzipped it, but left it called chumby_jamvm
Put the dongle on my Chumby
Relaunched the Chumby
SSHed in

had the following conversation
me:        java -version
it:           java: not found
me:        PATH=$PATH:/mnt/usb/chumby_jamvm/java/bin
me:        export PATH
me:        java -version
it:          java: cannot execute

before I go getting fancy... is there something simple I am missing?

Best & Thanks,
Carlyn

7 (edited by carlynm 2007-01-25 16:57:02)

Re: Java for chumby!

Update.... PS  I renamed chumby_jamvm to just jamvm... a little confusing I know

chumby:~# cd /mnt/usb/jamvm
chumby:/mnt/usb/jamvm# jamvm -version
jamvm: not found
chumby:/mnt/usb/jamvm# PATH=$PATH:/mnt/usb/jamvm
chumby:/mnt/usb/jamvm# export PATH
chumby:/mnt/usb/jamvm# jamvm -version
java version "1.4.2"
JamVM version 1.4.3
Copyright (C) 2003-2006 Robert Lougher <rob@lougher.org.uk>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2,
or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
chumby:/mnt/usb/jamvm#  jamvm ../../HelloChumby1
bootclasspath is empty!
chumby:/mnt/usb/jamvm# BOOTCLASSPATH=/mnt/usb/jamvm/lib/classes.zip
chumby:/mnt/usb/jamvm# export BOOTCLASSPATH 
chumby:/mnt/usb/jamvm# jamvm ../../HelloChumby1
Exception occurred while VM initialising.
java/lang/NoClassDefFoundError: java/lang/Thread
chumby:/mnt/usb/jamvm# java -version
/mnt/usb/jamvm: cannot execute
chumby:/mnt/usb/jamvm# BOOTCLASSPATH=$BOOTCLASSPATH:/mnt/usb/jamvm/lib/tools.zip
chumby:/mnt/usb/jamvm# export BOOTCLASSPATH 
chumby:/mnt/usb/jamvm# BOOTCLASSPATH=$BOOTCLASSPATH:/mnt/usb/jamvm/lib/glibj.zip
chumby:/mnt/usb/jamvm# export BOOTCLASSPATH 
chumby:/mnt/usb/jamvm# jamvm ../../HelloChumby1  
Cannot create system class loader
Exception occured while printing exception (java/lang/NoClassDefFoundError)...
Original exception was java/lang/UnsatisfiedLinkError
chumby:/mnt/usb/jamvm# javac ../../HelloChumby1
javac: not found

And this is where I stop for the night hoping someone who knows more about embeded JavaVM has a simple answer for me!


----Oh, in case you are wondering... THIS is HelloChumby1

public class HelloChumby1 {       
                                  
    public HelloChumby1() {       
    System.out.println("Bonjour Msr. Chumby");
            }                                 
                                              
    public void handleQuit()                  
    {                                         
        // If the application needs to save document/state before exiting, do so
        System.exit(0);                                                         
    }                                                                           
                                                                               
                                                                                
    public static void main(String args[]) {                                    
        new HelloChumby1();                                                     
    }                                                                           
}

so clearly all my classpath stuff is messed up... any advice on tracking all of them down?

Best,
-- Carlyn

Re: Java for chumby!

You almost had it.

I didn't include the javac compiler, so you'll have to compile your java program on a different platform - for instance, "HelloChumby1.java" would compile to "HelloChumby1.class". If you're looking to actually compile your java files on the chumby itself, you can either cross-compile something like Jikes, or perhaps use a java compiler written in java such as Kopi.

I believe I also supplied a script called "java" that would set up the classpaths, etc., that should be at the top level of your dongle - which should look like:

HelloChumby1.class
java
jamvm
lib/
   classes.zip
   libjavaio.so
   libjavalangreflect.so
   libjavanio.so
   readme
   glibj.zip
   libjavalang.so
   libjavanet.so        
   libjavautil.so
   tools.zip

Please let me know if this script is missing - it should contain:

#!/bin/sh
LD_LIBRARY_PATH=/mnt/usb/lib /mnt/usb/jamvm -mx8M -Xbootclasspath:/mnt/usb/lib/classes.zip:/mnt/usb/lib/glibj.zip $@

So... all you should have had to do was:

chumby:/mnt/usb# PATH=$PATH:/mnt/usb
chumby:/mnt/usb# java HelloChumby1

Re: Java for chumby!

You know, I totally woke up in the middle in the night thinking -- "it was because I had it in a directory, wasn't it"

Head smack.

YAY! It works!  Sort of...

chumby:~# PATH=$PATH:/mnt/usb
chumby:~# java /mnt/usb/HelloChumby1
java.lang.NoClassDefFoundError: HelloChumby1
   <<No stacktrace available>>
Caused by: java.lang.ClassNotFoundException: HelloChumby1 not found in java.lang.ClassLoader$1{urls=[file:/root/./], parent=null}
   at java.net.URLClassLoader.findClass(URLClassLoader.java:992)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:342)
   at java.lang.ClassLoader$1.loadClass(ClassLoader.java:1112)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:294)
chumby:~# cd /mnt/usb
chumby:/mnt/usb# java HelloChumby1
Bonjour Msr. Chumby

It looks like I have to be in the folder with the class file to run it? I can't refer to it with the path? I haven't seen that before... Is that just an embeded java thing?

THANK YOU!!!
-- Carlyn

Re: Java for chumby!

carlynm wrote:

It looks like I have to be in the folder with the class file to run it? I can't refer to it with the path? I haven't seen that before... Is that just an embeded java thing?

No, I don't think so, there's nothing particularly "embedded" about the JamVM - it's pretty much a stock lightweight JavaVM.  I chose it for its size and simplicity, but you could certainly build any of the others.

Chances are that there's some other parameter that needs to be sent to the jamvm from the java script that I'm missing.  If you can come up with any improvements, I'm more than willing to update the archive.  I'm not really a Java expert myself.

You might also take a look at the JamVM home page to see if the author has any pointers.

Re: Java for chumby!

Yeah... looks like I'm going to have to learn a little more myself since I'm trying to run processing apps (http://www.processing.org ) on the thing so our students can have some fun.

Processing can export as a linux binary but I couldn't get that to even try to run so I thought I'd do the jar file... You left the AWT toolkit in there right?

Well... I will let you know if I can come up with anything to help!  Thank you so much.

Best,
-- Carlyn

My current headache:

chumby:/mnt/usb# java -jar Bounce.jar
java.lang.reflect.InvocationTargetException
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at jamvm.java.lang.JarLauncher.main(JarLauncher.java:49)
Caused by: java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit
   at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:563)
   at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:103)
   at processing.core.PApplet.main(PApplet.java:6019)
   at Bounce.main(Bounce.java:49)
   at java.lang.reflect.Method.invokeNative(Native Method)
   ...2 more
Caused by: java.lang.UnsatisfiedLinkError: Native library `gtkpeer' not found (as file `libgtkpeer.so') in gnu.classpath.boot.library.path and java.library.path
   at java.lang.Runtime.loadLibrary(Runtime.java:763)
   at java.lang.System.loadLibrary(System.java:560)
   at gnu.java.awt.peer.gtk.GtkToolkit.<clinit>(GtkToolkit.java:111)
   at gnu.java.awt.peer.gtk.GtkToolkit.<init>(GtkToolkit.java:137)
   at java.lang.reflect.Constructor.constructNative(Native Method)
   at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
   at java.lang.Class.newInstance(Class.java:1163)
   at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:548)
   ...6 more

Re: Java for chumby!

I'm pretty sure AWT is in the classpath libraries, but I didn't build the GTK and GTK/java bindings in order for it to actually *work*, which is why you're getting the failures.

Of course, the source and build instructions are available smile

Unfortunately, we're under a deadline, so I can't spare an engineer to look at this.  I suspect, however, that a clever student could put this together in a couple of days, tops.

Re: Java for chumby!

Know enough to hand it off wink

Thank you for all your help so far and good luck with your deadlines!!!!

Best,
-- Carlyn

Re: Java for chumby!

Thanks - if/when you folks get this working, feel free to update the wiki page for the build instructions, and let me know and I'll update the binary tarball.  After all, that's what this whole hacking thing is about.

Also, when you get Processing to work, please create a wiki page here with information, even if it's just links back to your site.  I'd love to see what you're doing.  I have the front page locked to keep out spammers,  but let me know and I'll make a front page link for you.

I also appears that there's a newer version of JamVM with some bug fixes.

Re: Java for chumby!

Hi Duane and carlynm,

I noticed the thread today and I was wondering whether the processing apps are being able to run in the chumby now?
Thanks.
Ogun

Re: Java for chumby!

I haven't touched the Java stuff since then, so the answer is probably "no".

Frankly, this is probably only a couple of days' effort - I just don't have the bandwidth myself.  This would be a great project for some hacker looking for something productive to do.

What really needs to happen is for someone to port Sun's Jazelle-enabled ARM JVM, which would be quite snappy on the chumby.

Re: Java for chumby!

Well, I've lost a day of my life to attempting Java on chumby, and I'm not sure if I have anything to show for it or not.

I was able to compile the entire GTK chain for chumby (not sure how well it _works_, if at all, but the whole shebang compiled eventually, from libpng and libjpeg down to pango and gtk) targeting the framebuffer device.  But then it turns out that classpath's GTK bindings assume X11 and only X11 anyhow (as far as I can tell), so that was _several_ hours of work down the tubes.

Qt compiles fine(ish), on the other hand (thanks, jesperht), as do classpath's Qt bindings.  After compiling jamvm 1.5 and tossing it a -Dawt.toolkit=gnu.java.awt.peer.qt.QtToolkit, I'm stumped.

All I can get it to give me is the same "Native library `qtpeer' not found" error/stack trace that carlynm posted above (with qtpeer in place of gtkpeer).  The libqtpeer.so file exists, it's in the right format, I have permissions to it, I've tried putting it in a variety of directories, in my LD_LIBRARY_PATH, in the same directory as classes.zip, in a -Djava.library.path or -Dgnu.classpath.boot.library.path...  no change.  I'm baffled.  Same behavior if I substitute in my compiled classes.zip/glibj.zip with the 1.4.3 jamvm you provided.

An strace shows the library being happily opened, read, and mmapped, followed by a bunch of other (successful) Qt library opens, ending in a huge number of:

rt_sigprocmask(SIG_BLOCK, [USR1], NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [USR1], NULL, 8) = 0

pairs.  I'm not even sure if those are relevant or just an artifact of the chumby thinking hard smile

In any case, jesperht's pictureflow application runs enough that I don't believe it's a Qt problem (I haven't gotten it to really work yet, but it starts up and shows a cursor without crashing or throwing library errors), but I can't rule that out completely.  I'll dig into jamvm some more when I get the chance, I suppose.

Any ideas?

Re: Java for chumby!

Update: I got Qt (and jesperht's pictureflow) working just fine, as well as zlib, alsa, classpath, and jamvm.  The major problems before were prefixes and junk from GTK contaminating my build environment.  But I still get exactly the same error from jamvm/classpath regarding qtpeer (non-AWT Java appears to work).  Is there some reason the Qt peer shouldn't work with Qtopia?  Could something be running out of memory?  I'm grasping at straws here smile

19

Re: Java for chumby!

I noticed that freescale processor advertised accelerated java instructions. This probably doesn't take advantage of that?

20

Re: Java for chumby!

sym wrote:

I noticed that freescale processor advertised accelerated java instructions. This probably doesn't take advantage of that?

The instructions for building Java don't appear to be using any ARM926EJ-S processor specific compiler optimizations, so it's probably not taking full advantage of what the processor has to offer with regard to Java acceleration.  You might want to play around with various compiler opts and see what you get...

As Duane mentioned in a previous post, Jazelle is designed to make full use of the accelerated Java support in the ARM926EJ-S processor, so YMMV with any other Java VM.

Re: Java for chumby!

Unfortunately, Jazelle is not publicly documented, and requires a special license to get the necessary information.

There have been some attempts to reverse-engineer it - it would make a good project for someone that's interested in it.

Re: Java for chumby!

Hello -

I have a Java application that I'm interested in porting to the Chumby platform.

I've checked out the Wiki here:
http://wiki.chumby.com/mediawiki/index.php/Java

... but have a few questions:

1 - Is it possible to have a Java application run on the Chumby without a requiring command line interface?  Can it be auto-started if the Java dongle is plugged in?  Or any other way to make it user-friendly?

2 - Any special format required for the dongle, or simply format using FAT32?

3 - It seems the Wiki us using JavaVM 1.4.3, but when I visit the JavaVM project page version 1.5.1 is available for download here:
http://sourceforge.net/project/showfile … _id=583302
Does anyone know if this version of JavaVM will run on the Chumby?  Is there a pre-created dongle file for it anywhere?

4 - Can anyone comment on the performance of the Chumby running the JavaVM?  Could I expect performance similar to the Nokia N800?

Thanks in advance!

Re: Java for chumby!

Kremlar wrote:

Hello -

I have a Java application that I'm interested in porting to the Chumby platform.

I've checked out the Wiki here:
http://wiki.chumby.com/mediawiki/index.php/Java

... but have a few questions:

1 - Is it possible to have a Java application run on the Chumby without a requiring command line interface?  Can it be auto-started if the Java dongle is plugged in?  Or any other way to make it user-friendly?

Yes, you can use the "debugchumby" mechanism (as documented on the wiki and elsewhere) to boot directly into your application.

2 - Any special format required for the dongle, or simply format using FAT32?

Just format FAT32

3 - It seems the Wiki us using JavaVM 1.4.3, but when I visit the JavaVM project page version 1.5.1 is available for download here:
http://sourceforge.net/project/showfile … _id=583302
Does anyone know if this version of JavaVM will run on the Chumby?  Is there a pre-created dongle file for it anywhere?

Chances are very good that the same build instructions will work without modification for the new version.

4 - Can anyone comment on the performance of the Chumby running the JavaVM?  Could I expect performance similar to the Nokia N800?

It's probably very similar since the processors are roughly the same speed.

I should note that the JamVM port was a simple "this-is-how-you-port-stuff" example, not something we've used for any kind of production environment.  If you're serious, you might want to consider using another, more sophisticated, JVM.

Re: Java for chumby!

I should note that the JamVM port was a simple "this-is-how-you-port-stuff" example, not something we've used for any kind of production environment.  If you're serious, you might want to consider using another, more sophisticated, JVM.

Thanks for the reply, Duane.  Please excuse me if this is an ignorant question - could you point me in the direction of a JavaVM compatible with the Chumby that might be more sophisticated?  Could you give me an idea of what might be required to get it running on the Chumby?

Thanks again.

Re: Java for chumby!

Well, since we posted those instructions, Sun released their JVM under the GPL, and the source should be available on their site somewhere.  The instructions on the JamVM page of the wiki are very typical for such ports.

I picked JamVM back then because it was lightweight.