
can anyone tell me how to compile and run rmi in netbeans(6.9.1).here is my code,please help me!!!!
import java.rmi.*;
public interface Hello extends Remote {
public String sayHello() throws RemoteException;
}
Hello.java(file1)
import java.rmi.*;
import java.rmi.server.*;
public class HelloImpl extends UnicastRemoteObject implements Hello
{
public HelloImpl() throws RemoteException
{
super();
}
public String sayHello() throws RemoteException
{
return "Hello! Peter smith";
}
}
HelloImpl.java(file2)
import java.rmi.*;
import java.rmi.server.*;
public class HelloServer {
public static void main(String[] args) {
// TODO code application logic here
try
{
System.setSecurityManager(new RMISecurityManager());
Hello h=new HelloImpl();
Naming.rebind("server", h);
System.out.println("object is Registered");
System.out.println("server is waiting for client reqest...");
}catch(Exception e){System.out.println(e);}
}
}
HelloServer.java(file3)
import java.rmi.*;
public class HelloClient {
public static void main(String args[])
{
try{
Hello h=(Hello)Naming.lookup("rmi://localhost/server");
System.out.println("Client:Hello!");
System.out.println("Server :"+h.sayHello());
}catch(Exception e){System.out.println(e);}
}
}
HelloClient.java
These are the four files(remote interface,remote interface implementation,client and server class) and ipaddress given for HelloClient is 192.168.0.52(given in my book) but i replaced with localhost in lookup method since iam running in stand alone application.Can any one help me run this program please!!!
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.