Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9259805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:44:42+00:00 2026-06-18T12:44:42+00:00

How is it possible to export a java method or object using dbus? I

  • 0

How is it possible to export a java method or object using dbus?

I am writing this because the official documentation is very poor and it took me hours to figure out how to do it.

Ideally the DBus interface should go in a java package

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:44:43+00:00Added an answer on June 18, 2026 at 12:44 pm

    DBus.java

    import org.freedesktop.dbus.DBusInterface;
    import org.freedesktop.dbus.DBusInterfaceName;    
    
    @DBusInterfaceName("org.printer")
    public interface DBus extends DBusInterface {
        //Methods to export
        public void Print(String message);
    }
    

    Main.java

    import org.freedesktop.dbus.DBusConnection;
    import org.freedesktop.dbus.exceptions.DBusException;
    
    public class Main {    
        public static void main(String[] args) {
            Printer p = new Printer();
    
            try {
                DBusConnection conn = DBusConnection.getConnection(DBusConnection.SESSION);
                //Creates a bus name, it must contain some dots.
                conn.requestBusName("org.printer");
                //Exports the printer object
                conn.exportObject("/org/printer/MessagePrinter", p);
           } catch (DBusException DBe) {
               DBe.printStackTrace();
               conn.disconnect();
               return;
           }
        }
    }
    
    //Printer object, implements the dbus interface and gets
    //called when the methods are invoked.
    class Printer implements DBus {
        public boolean isRemote() {
            return false;
        }
    
        public void Print(String message) {
            System.out.println(message);
        }
    }
    

    You can try this out with qdbus from the shell, running:

    qdbus org.printer /org/printer/MessagePrinter org.printer.Print test
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I generated a very simple runnable jar file using Eclipse's Export-->Java-->Runnable Jar File function.
I'm writing a diagram editor in java. This app has the option to export
Is it possible to Export a MySQL to a CSV using the command line
Possible Duplicate: Is Java pass-by-reference? I found an unusual Java method today: private void
Is quaternion comparison possible? I'm writing a Java class of Quaternions and I want
Possible Duplicate: run shell command from java I want to export some variable so
I'm using iReport 2.0.4 to export some data to excel from a java application.
Is it possible to export my maven Java project on Eclipse to users that
Is it possible to export a flash movie with a transparent background as a
Is it possible to export a certificate and private key to a .pfx along

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.