java -jar jboss-remoting.jar
import org.jboss.remoting.*;
public class HelloWorldServer {
public static void main(String[] args) {
try {
HelloImpl hello = new HelloImpl();
RemotingServer server = new RemotingServer(null, 1234);
server.addInvocationHandler("hello", hello);
server.start();
System.out.println("Server started.");
} catch (Exception e) {
e.printStackTrace();
}
}
}
import org.jboss.remoting.*;
public class HelloWorldClient {
public static void main(String[] args) {
try {
RemotingClient client = new RemotingClient("localhost", 1234);
Hello hello = (Hello) client.createProxy("hello");
System.out.println(hello.sayHello());
client.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface Hello extends Remote {
String sayHello() throws RemoteException;
}