![]() |
Sun has open sourced their J2ME JVM (called CVM) under the umbrella of "phoneme advanced" with GPL. It seems that CVM performs better than jamvm or kaffe on the slug. The phoneme-advanced package has been added to the optware ipkg feed. You can simply install it by # ipkg update # ipkg install phoneme-advanced After installing phoneme-advanced ipk, the following shows a couple of things you can do: 1) Preliminary testing. $ cvm -version Product: phoneME Advanced (phoneme_advanced_mr2-b18) Profile: Foundation Profile Specification 1.1 JVM: CVM phoneme_advanced_mr2-b18 (mixed mode) $ cvm -cp /opt/lib/java/phoneme-advanced/testclasses.zip HelloWorld Hello world. $ cvm -cp /opt/lib/java/phoneme-advanced/testclasses.zip Test ... lots of output ... *CONGRATULATIONS: test Test completed with 411 tests passed and 0 failures *Output lines starting with a * should be checked for correctness *They can be compared to src/share/javavm/test/TestExpectedResult 2) Some Javascript scripting with rhino. $ wget ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_6R5.zip $ unzip rhino1_6R5.zip $ cd rhino1_6R5 $ cvm -cp js.jar org.mozilla.javascript.tools.shell.Main Rhino 1.6 release 5 2006 11 18 js> importPackage(java.util); js> print(new java.util.Date()); Tue May 23 12:23:01 GMT 2007 js> print(new Date()); Tue May 23 2007 12:23:09 GMT-0000 (GMT) js> quit(); 3) Jython 2.2.1 (with a small patch) runs under CVM, pystone number on mssii $ cvm -cp jython.jar org.python.util.jython Lib/test/pystone.py Pystone(1.1) time for 10000 passes = 20.986 This machine benchmarks at 476.508 pystones/second See this msg for detail 4) Servlet with jetty. On both your PC and your slug $ wget http://dist.codehaus.org/jetty/jetty-6.1.3.zip $ unzip jetty-6.1.3.zip On your PC, compile $ cd jetty-6.1.3 $ /usr/lib/jvm/j2sdk1.4.2_09/bin/javac \ -bootclasspath $J2ME_HOME/lib/foundation.jar:$J2ME_HOME/lib/btclasses.zip \ -classpath lib/servlet-api-2.5-6.1.3.jar:lib/jetty-util-6.1.3.jar:lib/jetty-6.1.3.jar \ -d examples/embedded/target/classes \ examples/embedded/src/main/java/org/mortbay/jetty/example/[MO]*.java Transfer examples/embedded/target/classes/ to your slug, $ cvm -cp \ lib/servlet-api-2.5-6.1.3.jar:\ lib/jetty-util-6.1.3.jar:\ lib/jetty-6.1.3.jar:\ examples/embedded/target/classes \ org.mortbay.jetty.example.MinimalServlets 2007-05-22 22:52:12.024::INFO: Logging to STDERR via org.mortbay.log.StdErrLog 2007-05-22 22:52:12.034::INFO: jetty-6.1.3 2007-05-22 22:52:12.313::INFO: Started SocketConnector @ 0.0.0.0:8080 $ w3m -dump http://localhost:8080/ Hello SimpleServlet Optware phoneme-advanced status (MR2? b34):
Note: if the procedure below does not work for you, please uninstall and then reinstall jamvm. After that it should work... 1) If using the Unslung release, the required packages can be installed as follows: (To date - 1 September 2005 - the packages do not yet exist in the OpenSlug ipkg repository, but the same result can be achieved by following the OpenSlugJavaInstallWorkaround) ipkg install classpath
ipkg install jamvm
ipkg install jikes
ipkg install zlib
ipkg install file (for networking)
2) Use your favorite editor (i.e: vi) to create a java program: filename: Test.java
class Test {
public static void main(String[] args) {
System.out.println("hello world");
}
}
3) to compile type on one line: /opt/bin/jikes -classpath /opt/share/jamvm/classes.zip:/opt/share/classpath/glibj.zip Test.java 4) to run type: /opt/bin/jamvm Test Example: bash-2.05b# jamvm Test Note: libmagic is missing in the jamvm package, and therefore the package 'file' needs to be installed for network java programs to work. Solution found here: |Debugging jamvm and classpath - 'ipkg install file' solves the problem. [15:06] <jacques> rwhitby-away, kaffe is a JVM, like jamvm [15:07] <dyoung-web> isnt the differnce sorta like dropbear vs openssh ? [15:07] <jacques> very apt analogy [15:07] <rwhitby-web> which is the openssh one :-) [15:07] <jacques> kaffe [15:08] <garpinc> That's why I did jamvm [15:08] <kergoth> i hear good things about kaffe. iirc there's a dev or two of it that drop by #oe on occasion [15:08] <jacques> it has its own classlib which is synced with gnu classlib relatively often [15:08] <jacques> jikes it a java compiler - compiles jave source code into bytecode [15:08] <garpinc> I synced directly with gnu classpath for my port [15:08] <jacques> I tried to get kaffe going with JIT but it's broken for armeb (and possibly armel) right now [15:09] <rwhitby-web> ok, let's put both alternatives (with the pros and cons of each) on that page. We do *not* need to decide between them :-) [15:09] <rwhitby-web> (unless they are conflicting, in which case we will just mark them as such) [15:10] <jacques> oh absolutely not - any more than we need to decide between openssh and dropbear - even less so actually since kaffe and jamvm and sablevm and ... can all coexist [15:10] <jacques> but kaffe will kick jamvs's ass in speed [15:10] <jacques> oops did I say that out loud? [15:10] <garpinc> http://www.mail-archive.com/kaffe@kaffe.org/msg07533.html [15:10] <garpinc> You're right jaques [15:11] <garpinc> But jamvm will kick kaffee on memory won't it. [15:12] <jacques> garpinc, well that's talking about if JIT is enabled in kaffe, which is broken for armeb right now [15:12] <jacques> but still, kaffe has a lot of optimizations that jamvm does not have, and jamvm is absolutely tiny compared to kaffe - pros and cons [15:12] <rwhitby-web> good, so it really is like dropbear and openssh - horses for courses [15:13] <jacques> yeah only things in common are jikes - compiler, and they both use gnu classlib derived classlibs [21/03/05] Hmmm. if there's no JIT jamvm will be faster -- kaffe's interpreter is unoptimised, jamvm uses direct-threading and stack-caching. It's 5x faster on ppc, which again doesn't have a working JIT. Of course, the JIT is faster.
/opt/bin/jikes -classpath /opt/share/jamvm/classes.zip:/opt/share/classpath/glibj.zip $*
view ·
edit ·
print ·
history ·
Last edited by Tumaini.
Based on work by Tumaini, BrianZhou, GerhardMuth, Philip Hart, rlougher, kaste, Vasile Dumitrescu, rwhitby, and Keith Garry Boyce. Originally by Keith Garry Boyce. Page last modified on August 25, 2008, at 10:20 AM
|