Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- import java.rmi.*;
- import java.rmi.registry.LocateRegistry;
- /**
- *
- * @author Jay
- */
- public class RMIServer extends java.rmi.server.UnicastRemoteObject
- implements RemoteServer {
- static int port = 1099;
- // Constructor for the method
- public RMIServer() throws RemoteException{
- }
- // This is the remote method which is accessible remotely wohoo
- public void helloYou() throws java.rmi.RemoteException
- {
- System.out.println("Hello you!");
- }
- public static void main(String[] args)
- {
- try
- {
- //port should be declared as static int port=1099;
- //LocateRegistry belongs to java.rmi.registry, you
- //have to import it
- LocateRegistry.createRegistry(port);
- System.out.println("1. RMI registry ready on port " + port + ".");
- System.out.println("------------------ " );
- RMIServer myServer = new RMIServer();
- Naming.rebind("rmi://localhost/RMIServer", myServer);
- }
- catch (Exception e)
- {
- System.out.println("Exception starting RMI registry:");
- e.getCause();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement