Dbus and jni is that possible ?

hannehomuth hannehomuth1 at gmx.de
Fri Jul 11 01:38:20 PDT 2008

Hi there,

Sorry that I ask a question again, but my app doesn't work.

A little overview agian. I wanna create an Dbus Service which calls some C
Methods which were wrapped  with jni (Java native interface) by me. But when
I call such a native Method on my RemoteObject I always get that
DbusExecutionException. But this Error occurs only on that native methods.
You might think there are some exceptions in this native methods, but there
aren't, because if tried to call this Methods by an alternative way (not
over dbus) and they worked all. Now my question. Could it be that dbus and
jni does not work together? Did someone tried this before?
I would be pleased if anyone had an good idea. 

Here the Mail from Yesterday If anyone wanna see some code

Hi again,

I've have another question that I can't resolve bymyself. I've connected my
own Dbus Service on the "SYSTEM_BUS" and now I've written a little Client
which calls some Methods on my remoteObject. The Interface for the
RemoteObject looks like this.

package de.sourcepark.PicoLcd;

import org.freedesktop.dbus.DBusInterface;

 * This is the Interface for the de.sourcepark.PicoLcd Service which
 * provides you all Methods you can call
 * @author jhomuth
public interface Services extends DBusInterface
  public void sayHello();
  public boolean isRemote();
  public void turnBackGroundLightOff();
  public void turnBackGroundLightOn();
  public void clearDisplay();
  public void setContrast(int level);
  public void setTextInOneLine(String text,int whichline, boolean
  public void setTextInTwoLines(String zeile1, String zeile2);

All Methods except the "sayHello" Method call an native Method which was
wrapped with jni from me.
Here the code of my RemoteObject

public class Service implements DBusInterface{

    public boolean isRemote() {
        return true;
     * Prints the Word Hello on the Console. Only for testing
    public void sayHello()
        System.out.println("sayHello aufgerufen über den Dbus");
     * This Method turns the backlight of the PicoLcd to off
    public void turnBackGroundLightOff()
        System.out.println("Mache Licht aus");
        PicoLCDWrappedMethods picoLcdMethods = new PicoLCDWrappedMethods();
     * This Method turns the backlight of the PicoLcd to on
    public void turnBackGroundLightOn()
        System.out.println("Mache Licht an");
        PicoLCDWrappedMethods picoLcdMethods = new PicoLCDWrappedMethods();
     * This Methods clears all Text on the Display
    public void clearDisplay()
        System.out.println("Lösche das Display");
        PicoLCDWrappedMethods picoLcdMethods = new PicoLCDWrappedMethods();

There are more methods in here (as you can see in the Interface above) but I
let them out here in this posting.

And here the Wrapper If you wanna know

 * This class wraps the C calls to Java Methods.
 * Here all nesseary methods will be wrapped so that we could
 * call them trough our java code
 * @author jhomuth
public class PicoLCDWrappedMethods {

    public PicoLCDWrappedMethods() {
       System.out.println("Load the Library");      
       System.out.println("Library was loaded");
   public native void turnLightOn();
    public native void turnLightOff();
    public native void clearDisplay();
    public native void setContrast(int level);
    public native void setLed(int whichLed, int status);
    private native void setText(int row, int colum, String text);

And here is a snippet outa the C "Class" which was written for the wrapper

//This Method clears the Display
JNIEXPORT void JNICALL Java_picolcdserver_PicoLCDWrappedMethods_clearDisplay
(JNIEnv *env, jobject jobj)
    printf("ClearDisplay in der Native Methode");
     usblcd_operations *mylcd;
    /* init hid device and usblcd_operations structure */
    mylcd = new_usblcd_operations();
     /* init the USB LCD */

As I sad in the Mail before, if I uses the same wrapper classes in my own
written socket server everything worked fine, But if I call this native
methods on my dbus RemoteObject I always get an DbusExecutionException. But
I have to say the sayHello Method, which has nothing todo with the wrapper
works.!?! I could think the wrapper is wrong but as I already sad it worked
with the socket server. So does anyone know why this damm exception comes,
and how to fix that?

Thx for reading this long post in bad english and your answers 
View this message in context: http://www.nabble.com/Dbus-and-jni-is-that-possible---tp18399205p18399205.html
Sent from the Free Desktop - dbus mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/dbus/attachments/20080711/82f36274/attachment.html 

More information about the dbus mailing list