I'm trying to register object on dbus using dbus-java from org.freedesktop. According to documentation such operation requires: creating DBusConnection, creating object and calling method exportObject on DBusConnection.
My Code:
DatabaseAccessImpl dbAccess = new DatabaseAccessImpl();
System.out.println("Object created.");
System.out.println("Trying to connect session bus");
try {
conn = DBusConnection.getConnection(DBusConnection.SESSION);
} catch(DBusException ex) {
ex.printStackTrace();
}
System.out.println("Connected to session bus.");
System.out.println("Trying to register dbus object");
try {
conn.exportObject("/obj/path", new DatabaseAccessImpl());
} catch (DBusException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
where:
DatabaseAccessImpl is implementation of interface created automatically by CreateInterface (xml worked fine while using with c++ (qt)).
dbAccess will send on dbus some data (mostly ints) from database. It all work good in Qt but I have to reimplement it in java (not my language).
For using dbus-java you have to install libmatthew-debug and execute program with
-Djava.library.path=/usr/lib/jni
I'm working on Linux Mint.