<br clear="all">I want to call a remote object method using DBus. I developed some  code for that taking some help from the source code of org/freedesktop/dbus/test/Test.java and org/freedesktop/dbus.test/TestRemoteInterface.java.<br>
But I get some exception when i run my program.<br><br>My code along with terminal output is as below :<br>                                                          <b>&lt;DBusInt.java&gt;</b><br><br>package pack1;<br>import org.freedesktop.dbus.DBusInterface;<br>
<br><br>//import <a href="http://org.apertium.Info">org.apertium.Info</a>; // The interface we use to access <a href="http://org.apertium.info/">org.apertium.info/</a><br><br>public interface DBusInt extends DBusInterface{<br>
public String myfun();<br>}<br><br>                                                      <b> &lt;TestDBus.java&gt;<br></b><br><br>import org.freedesktop.DBus;<br>import org.freedesktop.dbus.exceptions.DBusException;<br>import org.freedesktop.dbus.*;<br>
import org.freedesktop.DBus.Peer;<br>import pack1.DBusInt;<br><br><br><br><br>//import <a href="http://org.apertium.Info">org.apertium.Info</a>; // The interface we use to access <a href="http://org.apertium.info/">org.apertium.info/</a><br>
<br><br>class testclass implements DBusInt<br>{<br>       private DBusConnection conn;<br><br>       public testclass(DBusConnection conn)<br>       {<br>              this.conn = conn;<br>       }<br><br>     /** Local classes MUST implement this to return false */<br>
       public boolean isRemote() { return false; }<br><br>    public String myfun()<br>       {<br>        System.out.println(&quot;Within myfun&quot;);<br>             return &quot;This is a response from myfun !!&quot;;<br>
       }<br><br><br>}<br><br><br>public class TestDBus{<br><br>    static DBusConnection serverconn = null;<br>       static DBusConnection clientconn = null;<br><br>    public static void main(String args[])throws DBusException{<br>
<br>            serverconn = DBusConnection.getConnection(DBusConnection.SESSION);<br>              clientconn = DBusConnection.getConnection(DBusConnection.SESSION);<br>      <br>              System.out.println(&quot;Registering Name&quot;);<br>
              serverconn.requestBusName(&quot;foo.bar.Test&quot;);<br><br>        System.out.println(&quot;Listening for Method Calls&quot;);<br>              testclass tclass = new testclass(serverconn);<br><br>              /** This exports an instance of the test class as the object /Test. */<br>
              serverconn.exportObject(&quot;/Test&quot;, tclass);<br><br>         System.out.println(&quot;Calling Method0/1 &quot;);<br>              /** This gets a remote object matching our bus name and exported object path. */<br>
             <b> DBusInt tri = (DBusInt)clientconn.getPeerRemoteObject(&quot;foo.bar.Test&quot;, &quot;/Test&quot;);</b><br>              System.out.println(&quot;Got Remote Object: &quot;+tri);<br><br>              /** Call the remote object and get a response. */<br>
              String rname = tri.myfun();<br>              System.out.println(&quot;Got Remote Name: &quot;+rname);<br>        //String str=(DBusInt)clientconn.getPeerRemoteObject(&quot;foo.bar.Test&quot;, &quot;/Test&quot;).myfun();<br>
    }<br>}<br><br>                                                         <b>&lt;TERMINAL OUTPUT&gt;<br><br></b>Registering Name<br>Listening for Method Calls<br>Calling Method0/1<br>Exception in thread &quot;main&quot; java.lang.ClassCastException: $Proxy2 cannot be cast to pack1.DBusInt<br>
        at TestDBus.main(TestDBus.java:57)<br><br><br><br>plz help me to fix this exception. I have bold marked the line in TestDBus.java which is causing exception.<br><br>Thanks in advance!!<br>-- <br>Regards,<br>Shiv Nath Kumar<br>