Java Services

From WebOS Internals
Jump to navigation Jump to search

We will do a quick overview on how to create a Java-based service and get it running under the dbus system.

The service framework of webOS depends largely on dbus, but Palm wrote most of the services in Java (there are maybe two or three native services). They've used a dbus Java library in order to communicate with the dbus and wrote more libraries to make the creation of these services much easier. The library of interest is serviceframework.jar, located under /usr/lib/luna/java.

All Java services extend from either the LunaServiceThread class directly or from a subclass of LunaServiceThread.

Installation / packaging


<source lang="text"> /etc/event.d/org.webosinternals.hello /usr/share/dbus-1/system-services/org.webosinternals.hello /usr/lib/luna/java/ </source>


<source lang="text"> [D-BUS Service] Name=org.webosinternals.hello Exec=/usr/bin/luna-helper 'luna://com.palm.vm/launch' '{"serviceName":"org.webosinternals.hello","className":""}' </source>

/etc/event.d/org.webosinternals.hello: "I don't believe this is necessary... Where did it come from? PuffTheMagic 03:19, 10 August 2009 (UTC)"

"At the time I've created this Java service, the configuration file for the service under /usr/share/dbus-1/system-services directory did nothing to start the service. I could not find out why, so I've just created the event.d script to start it up. If it isn't needed anymore or there is a correct way of starting the service, please edit it. ShinAli 12:38, 6 October 2009 (UTC)"

I have just tried this on my own Palm Pre device with WebOS 1.2.1 installed. Services still do not start automatically by virtue of being included in /usr/share/dbus-1/system-services. As far as I can tell, the /etc/event.d/org.webosinternals.hello or equivalent startup script is still necessary. In addition, the services at do startup in completely different ways, and a couple of them use scripts as noted above. --Coderkevin 18:13, 5 November 2009 (UTC)

See the services at for the recommended way to start services.

<source lang="text"> start on started java-serviceboot

script /usr/bin/luna-helper 'luna://com.palm.vm/launch' '{"serviceName":"org.webosinternals.hello","className":""}' end script </source>


<source lang="text"> META-INF/ META-INF/MANIFEST.MF org/webosinternals/services/HelloService.class </source>