Java Support in webOS

= Advice =

 Note: In first semester 2010, Palm has announced that in a future version of webOS, the JVM will no longer be included (more information here. And since webOS 2.1.0, Java support in webOS was removed and the projects which depend on the OasisVM JVM "suddenly fail" after this update.

'''Now you can backport Palm Java JVM OasisVM (JRE) on webOS 2.0 and above devices : http://www.webos-internals.org/wiki/How_to_keep_the_Palm_Java_JVM_OasisVM_%28JRE%29_with_webOS_2.0_and_above

= The JVM =

There is a JVM in webOS. His name is OasisVM.

You can have more information when you use this command-line :

root@palm-webos-device:/# javahy --help OasisVM: Build 107 Copyright 2005, Iventor, Inc. All Rights Reserved Build options are: Oasis-Linux-WebConsole-LightLocks-Generational-GCC_Goto_Optimizations-SingleSlot usage: OasisVM [options] [classfile [args]]

Note: OasisVM Build 107 with webos 1.4.1 and 1.4.5, OasisVM Build 96.2 with webOS 1.1.0 The web server for iventor.com return only 404 errors. We can see a version of this website at www.iventor.com from a couple of years ago. This company was founded by Paul Mercer.

Options in OasisVM Build 107 are :

Options are: -classpath or -cp -bootclasspath or -bcp -h, --help                   Display help and exit -m, --object-heap-size Set object heap size -s, --vm-stack-size    Set java stack size -t, --nm-stack-size    Set native methods stack size -Xstacklimit=                    Set java stack limit -d, run the VM as a daemon -Xms set object heap size (variant) -Xmx set object heap size (variant) -Xnh set native code heap size -Xint interpreter only (disable the JIT) -Xpreload= file containing list of classes to preload before running main -Xpreloadout= output file containing list of classes we loaded -verbose:[class|threads|gc|warnings] print extra debugging info -Xprofile print periodic profiler stats -Xgcnocopy use a non-copying garbage collection -Xconservative use conservative collection -Xexact use exact collection -Xtraceall trace all classes (no class unloading) -Xgcagressive agressive garbage collection -Xgcdelay     wait X ms before garbage collection begins -Xnoyank      disable rug yanking -Xnossa       disable SSA optimizations -XnoSSA       disable SSA optimizations - -nojit synonym for -Xint -Xrandcomp    random JIT compiles -Xbreak       debug break after initializing the VM -Xbootbreak    debug break before initializing the VM -XX:+HeapDumpOnOutOfMemoryError        dump heap to oom.hprof on OOM error -Xstackdump= - -ms                   enable memory stats -Xxray=fifoname       enable xray output -Xwebconsole  enable web console at 127.0.0.1:8083

The Java process used by webOS :

root@castle:/etc# ps -ax -o user,cmd | grep java USER CMD ... root@palm-webos-device:/# ps -ax -o user,cmd | grep java root    /usr/lib/jvm/java-1.5-palm/bin/java -Xexact -m 10M -Djava.library.path=/usr/lib/jvm/java-1.5-palm/bin :/usr/lib/jvm/java-1.5-palm/jre/bin :/usr/lib -Dvm.boot.library.path=/usr/lib/jvm/java-1.5-palm/jre/bin -bootclasspath /usr/lib /jvm/java-1.5-palm/lib/rt.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/luni.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/nio.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/nio_char.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/security.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/archive.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/logging.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/text.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/icu4j_3.8/icu4j-3_8.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/icu4j_3.8/icu4j-charsets-3_8.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/ext/icu4jni.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/sql.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/regex.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/math.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/auth.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/crypto.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/x-net.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/boot/annotation.jar :/usr/lib/jvm/java-1.5-palm/jre/lib/ext/bcprov.jar -Djava.home=/usr/lib/jvm/java-1.5-palm/jre -Djava.security.properties=/usr/lib/jvm/java-1.5-palm/jre/lib/security/java.security -Xstackdump=/var/log/stackdump.txt -Xms10M -Xmx15M -classpath /usr/lib/luna/java/Async.jar :/usr/lib/luna/java/CarrierNetworkSettings.jar :/usr/lib/luna/java/Customization.jar :/usr/lib/luna/java/DefaultDatabaseBuilder.jar :/usr/lib/luna/java/Fnmbl-ClientApi.jar :/usr/lib/luna/java/Fnmbl-ClientFramework.jar :/usr/lib/luna/java /InterfaceRegistry.jar :/usr/lib/luna/java/MediaEvents.jar :/usr/lib/luna/java/Photos.jar :/usr/lib/luna/java/Utils.jar :/usr/lib/luna/java/accounts.jar :/usr/lib/luna/java/accountservices.jar :/usr/lib/luna/java/activerecord.jar :/usr/lib/luna/java/backup.jar :/usr/lib/luna/java/calendar.jar :/usr/lib/luna/java/contacts.jar :/usr/lib/luna/java/dataimport.jar :/usr/lib/luna/java/datamigration.jar :/usr/lib/luna/java/deviceprofile.jar :/usr/lib/luna/java/devicewipe.jar :/usr/lib/luna/java/facebook.jar :/usr/lib/luna/java/findapps.jar :/usr/lib/luna/java/gdata.jar :/usr/lib/luna/java/jWAP.jar :/usr/lib/luna/java/java-md5.jar :/usr/lib/luna/java/joda-time-1.5.2.jar :/usr/lib/luna/java/json.jar :/usr/lib/luna/java/ksoap2-j2se-full-2.1.1.jar :/usr/lib/luna/java/libmatthew-java-0.7.jar :/usr/lib/luna/java/location.jar :/usr/lib/luna/java/lunaservice.jar :/usr/lib/luna/java/mail.jar :/usr/lib/luna/java/messaging.jar :/usr/lib/luna/java/messagingrouter.jar :/usr/lib/luna/java/minidbus-java-2.4.jar :/usr/lib/luna/java/notes.jar :/usr/lib/luna/java/packageinfo.jar :/usr/lib/luna/java/palmipc.jar :/usr/lib/luna/java/pim.jar :/usr/lib/luna/java/pimsync.jar :/usr/lib/luna/java/rfc2445.jar :/usr/lib/luna/java/scheduler.jar :/usr/lib/luna/java/serviceboot.jar :/usr/lib/luna/java/serviceframework.jar :/usr/lib/luna/java/sqlitejdbc-v053.jar :/usr/lib/luna/java/superlog.jar :/usr/lib/luna/java/tasks.jar :/usr/lib/luna/java/telephony.jar :/usr/lib/luna/java/zone-info.jar -DtimeZoneId=CET -Djava.util.logging.config.file=/etc/logging.properties -verbose:gc -Xwebconsole -Xoomexit -Xoomreport=/var/javaoom/oom.1149.txt com.palm.serviceboot.ServiceBoot start

= The Java Classes =

The OasisVM JVM in webos use Java Classes from Harmony to Implement the Java Platform Standard Edition 5.

In webOS 1.4.1 for Harmony and OasisVM versions, we have : root@palm-webos-device:/# ipkg list | grep harmony harmony - 5.0.r603534-67 - harmonykernel - 1.0.0-21 - oasisharmonyvm - 1.0-107 -

Note : revision 603534 was commit in the Harmony SVN the 12th December 2007 and Harmony 5.0 M4 stable was release the 2007-12-19 (History relases here).

The revision 603534 for Harmony is old, more than 2 years, and there was improvements in Harmony :
 * 5.0 M6 with new JIT optimizations, improved VM threading design
 * 5.0 M9 with performance: across multiple areas, including class library improvements and JIT compiler global propagation optimizations, integer MUL/DIV/REM strength reduction,

The JVM Files
root@qemux86:/# ipkg files oasisharmonyvm Package oasisharmonyvm (1.0-107) is installed on root and has the following files: /usr/bin/javahy /usr/bin/jps /usr/bin/jthreads /usr/bin/jtop /usr/lib/jvm/java-1.5-palm/bin/.debug/libvmi.so                                   /usr/lib/jvm/java-1.5-palm/bin/java /usr/lib/jvm/java-1.5-palm/bin/libvmi.so

The Harmony Kernel
root@qemux86:/# ipkg files harmonykernel Package harmonykernel (1.0.0-21) is installed on root and has the following files: /usr/lib/jvm/java-1.5-palm/lib/rt.jar

The Harmony Files
root@qemux86:/# ipkg files harmony Package harmony (5.0.r603534-67) is installed on root and has the following files: /usr/lib/jvm/java-1.5-palm/jre/bin/harmony.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_ca.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_cs.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_de.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_es.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_fr.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_hu.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_it.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_ja.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_ko.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_pl.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_pt_BR.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_ru.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_sk.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_sl.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_tr.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_zh.properties /usr/lib/jvm/java-1.5-palm/jre/bin/harmony_zh_TW.properties /usr/lib/jvm/java-1.5-palm/jre/bin/libICUInterface34.so (only in X86 webos 1.4.5 emulator) /usr/lib/jvm/java-1.5-palm/jre/bin/libhyarchive.so                                /usr/lib/jvm/java-1.5-palm/jre/bin/libhyauth.so                                    /usr/lib/jvm/java-1.5-palm/jre/bin/libhycharset.so                                 /usr/lib/jvm/java-1.5-palm/jre/bin/libhyluni.so                                    /usr/lib/jvm/java-1.5-palm/jre/bin/libhynio.so                                     /usr/lib/jvm/java-1.5-palm/jre/bin/libhyprt.so                                     /usr/lib/jvm/java-1.5-palm/jre/bin/libhythr.so                                     /usr/lib/jvm/java-1.5-palm/jre/bin/libhyxnet.so                                    /usr/lib/jvm/java-1.5-palm/jre/bin/libhyzlib.so /usr/lib/jvm/java-1.5-palm/jre/bin/libicuuc.so   (only in Arm webOS 1.4.5 for devices) Lib ICU4C 3.4.1 /usr/lib/jvm/java-1.5-palm/jre/lib/boot/annotation.jar /usr/lib/jvm/java-1.5-palm/jre/lib/boot/archive.jar /usr/lib/jvm/java-1.5-palm/jre/lib/boot/auth.jar /usr/lib/jvm/java-1.5-palm/jre/lib/boot/crypto.jar /usr/lib/jvm/java-1.5-palm/jre/lib/boot/logging.jar /usr/lib/jvm/java-1.5-palm/jre/lib/boot/luni.jar /usr/lib/jvm/java-1.5-palm/jre/lib/boot/math.jar /usr/lib/jvm/java-1.5-palm/jre/lib/boot/nio.jar /usr/lib/jvm/java-1.5-palm/jre/lib/boot/nio_char.jar /usr/lib/jvm/java-1.5-palm/jre/lib/boot/regex.jar /usr/lib/jvm/java-1.5-palm/jre/lib/boot/security.jar /usr/lib/jvm/java-1.5-palm/jre/lib/boot/sql.jar /usr/lib/jvm/java-1.5-palm/jre/lib/boot/text.jar /usr/lib/jvm/java-1.5-palm/jre/lib/boot/x-net.jar /usr/lib/jvm/java-1.5-palm/jre/lib/boot/icu4j_3.8/icu4j-3_8.jar (only in Arm webOS 1.4.5 for devices) ICU4J 3.8.0 /usr/lib/jvm/java-1.5-palm/jre/lib/boot/icu4j_3.8/icu4j-charsets-3_8.jar (only in Arm webOS 1.4.5 for devices) ICU4J 3.8.0 /usr/lib/jvm/java-1.5-palm/jre/lib/content-types.properties /usr/lib/jvm/java-1.5-palm/jre/lib/logging.properties /usr/lib/jvm/java-1.5-palm/jre/lib/net.properties /usr/lib/jvm/java-1.5-palm/jre/lib/rowset.properties /usr/lib/jvm/java-1.5-palm/jre/lib/ext/bcprov.jar  (only in Arm webOS 1.4.5 for devices) /usr/lib/jvm/java-1.5-palm/jre/lib/ext/icu4jni.jar    (only in Arm webOS 1.4.5 for devices) /usr/lib/jvm/java-1.5-palm/jre/lib/security/java.policy /usr/lib/jvm/java-1.5-palm/jre/lib/security/java.security

Harmony standard jar files removed by Palm in his Harmony package
When you check the file http://archive.apache.org/dist/harmony/milestones/M4/apache-harmony-jre-r603534-linux-x86-32-snapshot.tar.gz,  you can see that Palm remove the folowing files in the folder /usr/lib/jvm/java-1.5-palm/jre/lib/boot/ :  accessibility.jar, antlr-2.7.5.jar, applet.jar, awt.jar, bean.jar, concurrent.jar, image-io.jar, instrument.jar, jndi.jar, lang-management.jar, luni-kernel-stubs.jar, misc.jar, pack200.jar, prefs.jar, print.jar,  rmi.jar, sound.jar, suncompat.jar, swing.jar, vmmagic-20070207.jar.

Specific Palm Java packages
root@qemux86:/# ipkg list | grep java gdata-java-client - 1.0-7 - java-activerecord - 1.0-100 - java-async - 1.0-6.1 - java-com.palm.accounts - 1.0-105 - java-com.palm.accountservices - 1.0-100 - java-com.palm.backup - 1.0-92 - java-com.palm.calendar - 1.0-117 - java-com.palm.carriernetworksettings - 1.0-88.4 - java-com.palm.contacts - 1.0-123 - java-com.palm.customization - 1.0-39 - java-com.palm.dataimport - 1.0-25 - java-com.palm.datamigration - 1.0-16 - java-com.palm.defaultdatabasebuilder - 1.0-7 - java-com.palm.deviceprofile - 1.0-43 - java-com.palm.devicewipe - 1.0-8 - java-com.palm.facebook - 1.0-18 - java-com.palm.findapps - 1.0-1.1 - java-com.palm.interfaceregistry - 1.0-3.1 - java-com.palm.location - 1.0-67 - java-com.palm.mail - 1.0-339 - java-com.palm.mediaevents - 1.0-12 - java-com.palm.messaging - 1.0-229 - java-com.palm.messagingrouter - 1.0-46 - java-com.palm.notes - 1.0-3 - java-com.palm.packageinfo - 1.0-9.1 - java-com.palm.photos - 1.0-6 - java-com.palm.pim - 1.0-198 - java-com.palm.pimsync - 1.0-142 - java-com.palm.scheduler - 1.0-38 - java-com.palm.serviceboot - 1.0-42 - java-com.palm.superlog - 1.0-19.1 - java-com.palm.tasks - 1.0-28 - java-com.palm.telephony - 1.0-192.1 - java-md5 - 1.0-3 - java-service - 1.0-58 - java-utils - 1.0-64 - java-zone-info - 1.0-2 - libmatthew-java - 0.7-r2 - palmipc-java - 1.0.0-21 -

detailed files in each palm specific package
root@qemux86:/# ipkg files java-async Package java-async (1.0-6.1) is installed on root and has the following files: /usr/lib/luna/java/Async.jar

root@qemux86:/# ipkg files java-activerecord Package java-activerecord (1.0-100) is installed on root and has the following files: /etc/palm/activerecord.conf /usr/bin/cleanupDBFiles.sh /usr/bin/mvDBFiles.sh /usr/lib/luna/java/activerecord.jar

root@qemux86:/# ipkg files gdata-java-client Package gdata-java-client (1.0-7) is installed on root and has the following files: /usr/lib/luna/java/gdata.jar

root@qemux86:/# ipkg files java-md5 Package java-md5 (1.0-3) is installed on root and has the following files: /usr/lib/luna/java/java-md5.jar

root@qemux86:/# ipkg files java-service Package java-service (1.0-58) is installed on root and has the following files: /usr/lib/luna/java/serviceframework.jar

root@qemux86:/# ipkg files java-utils Package java-utils (1.0-64) is installed on root and has the following files: /etc/logging.properties /usr/lib/libOasisUtilJni.so /usr/lib/luna/java/Utils.jar

root@qemux86:/# ipkg files java-zone-info Package java-zone-info (1.0-2) is installed on root and has the following files: /usr/lib/luna/java/zone-info.jar

Matthew Johnson's Java Libraries : Unix Sockets Library, Debug Library, CGI Library, I/O Library root@qemux86:/# ipkg files libmatthew-java Package libmatthew-java (0.7-r2) is installed on root and has the following files: /usr/lib/libunix-java.so /usr/lib/luna/java/libmatthew-java-0.7.jar

root@qemux86:/# ipkg files palmipc-java Package palmipc-java (1.0.0-21) is installed on root and has the following files: /usr/lib/luna/java/minidbus-java-2.4.jar /usr/lib/luna/java/palmipc.jar

= Compile and Test the Hello World program on Palm webOS =

1) You need a Java compiler on your computer (Linux, Windows, MacOS X). 2) Create a file HelloWorld.java. 3) Add the following lines in the file HelloWorld.java : public class HelloWorld {   public static void main(String[] args) {       System.out.println("Hello, World");   } } 4) Compile the sources with the command line : javac HelloWorld.java 5) Copy the HelloWorld.class on the Palm emulator by scp -P 5522 HelloWorld.class root@localhost:/media/internal or by copying the file on the root of the partition disk when your Palm device is connected as USB device. 6) Launch novacom proces if it is not launched. 7) Launch novaterm terminal : novaterm 8) Go in the /media/internal folder root@qemux86# cd /media/internal 10) Execute your java program : root@qemux86:/media/internal# javahy HelloWorld Command line arguments:  /usr/lib/jvm/java-1.5-palm/bin/java -Xexact -m 10M -Djava.library.path=/usr/lib/jvm/java-1.5-palm/bin:/usr/lib/jvm/java-1.5-palm/jre/bin:/usr/lib -Dvm.boot.library.path=/usr/lib/jvm/java-1.5-palm/jre/bin  -bootclasspath /usr/lib/jvm/java-1.5-palm/lib/rt.jar:/usr/lib/jvm/java-1.5-palm/jre/lib/boot/luni.jar:/usr/lib/jvm/java-1.5-palm/jre/lib/boot/nio.jar:/usr/lib/jvm/java-1.5-palm/jre/lib/boot/nio_char.jar:/usr/lib/jvm/java-1.5-palm/jre/lib /boot/security.jar:/usr/lib/jvm/java-1.5-palm/jre/lib/boot/archive.jar:/usr/lib/jvm/java-1.5-palm/jre/lib/boot/logging.jar:/usr/lib/jvm/java-1.5-palm/jre/lib/boot/text.jar:/usr/lib/jvm/java-1.5-palm/jre/lib/boot/icu4j_3.8/icu4j-3_8.jar: /usr/lib/jvm/java-1.5-palm/jre/lib/boot/icu4j_3.8/icu4j-charsets-3_8.jar:/usr/lib/jvm/java-1.5-palm/jre/lib/ext/icu4jni.jar:/usr/lib/jvm/java-1.5-palm/jre/lib/boot/sql.jar:/usr/lib/jvm/java-1.5-palm/jre/lib/boot/regex.jar:/usr/lib/jvm/java- 1.5-palm/jre/lib/boot/math.jar:/usr/lib/jvm/java-1.5-palm/jre/lib/boot/auth.jar:/usr/lib/jvm/java-1.5-palm/jre/lib/boot/crypto.jar:/usr/lib/jvm/java-1.5-palm/jre/lib/boot/x-net.jar:/usr/lib/jvm/java-1.5-palm/jre/lib/boot/annotation.jar: /usr/lib/jvm/java-1.5-palm/jre/lib/ext/bcprov.jar -Djava.home=/usr/lib/jvm/java-1.5-palm/jre -Djava.security.properties=/usr/lib/jvm/java-1.5-palm/jre/lib/security/java.security -Xstackdump=/var/log/stackdump.txt HelloWorld @@@@ ClassLibrary initialize begins... Harmony interface GetInitArgs not implemented @@@@ ClassLibrary initialized... elapsed=147 ms Hello, World



Note : use javahy -strace YourJavaClasse to debug your program

= No AWT or Swing support for Java applications with a Graphic User Interface in webOS =

As you can see above, you can use java program in console text mode in Palm webOS. But if you try to use the HelloWorld program with the Swing Graphic User Interface, you have this error : root@qemux86:/media/internal# javahy HelloWorld2 ... @@@@ ClassLibrary initialized... elapsed=96 ms java.lang.ClassNotFoundException: javax/swing/JOptionPane at HelloWorld2.main(HelloWorld2.java:3)

You have this error because all the standard Java Classes in Harmony are not all available in the Palm WebOS package harmony - 5.0.r603534.  The files awt.jar and swing.jar are not in the folder /usr/lib/jvm/java-1.5-palm/jre/lib/boot as you can see in Harmony files list.

= The OasisVM JVM in webOS used only for for back-end services ? =

Several users report that the JVM in Palm webOS is only used for back-end services/system services in theses posts : Post1, Post2.

= Upgrading Java support on webOS devices =

Firt choice
Keeping OasisVM JVM and upgrading Harmony Java classes that support JSE 1.5. The problem is that Harmony is now a death project with no updates since 2010-09-15  and Apache Harmony is retired at the Apache Software Foundation since Nov 16, 2011.  Then need to install a cross compiling environment or PDK for ARM chips on your computer. and  then compile Harmony Java classes by using steps here : http://harmony.apache.org/quickhelp_contributors.html  and here :  Harmony with Linux/ARM port?  http://markmail.org/message/vk7iezeqggewlasx 
 * http://www.webos-internals.org/wiki/Cross_Compiling
 * http://www.webos-internals.org/wiki/WebOS_Internals_PDK
 * http://www.webos-internals.org/wiki/PDK_on_Linux

Secondth choice
Replacing OasisVM JVM by an other JVM (JamVM is the best choice among the others JVM.With Dacapo tests, it have good results as as you can see at the end of this page. JamVM use a little memory and the next release is optimised for ARMv7a architecture as chips in Palm- and + and 2. You can use JamVM with Eclipse, Jedit, derby as the JamVM's developer said in his blog here.You can use Gnu classpath or OpenJDK, suppoerted by JamVM, for replacing Harmony Java classes as Java classes with JSE 1.6 support, but because there is no updates for GNU Classpath since 5 February 2009, the best choice here is now to use OpenJDK classes.(Open)JDK6 for embedded ARM.

= See Also =
 * Palm Pre's WebOS includes Harmony (mailing list dev@harmony.apache.org)
 * Java Services in Palm webOS (wiki webos-internals.org)
 * Java ME (Forum Precentral)