I am learning java and now my excersize is bulding calculator using RMI.
Now, i have allready write all calculator code(with the opertors and all the calculation - all the math code...) but my problem is how to use RMI to run it.
I saw on google serch that i need clinet and server code but i dont really understand it..
I hope to get simple example of how my code should be looking like so i will take my calculator and build on it.
Can someone please help ?
here is my server code :import java.rmi.Naming;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
public class ServerProgram
{
public ServerProgram()
{
try
{
Registry registry = LocateRegistry.getRegistry();
System.out.println("1");
CalculatorImpl c = new CalculatorImpl();
String name = "rmi://host:port/name";
System.out.println("2");
Naming.rebind(name, c);
System.out.println("Service is bound......");
}
catch (Exception e)
{
}
}
public static void main(String[] args)
{
new ServerProgram();
}
}
but when i run it i see on debug that it is stuck on Naming.rebind(name, c), and i dont know why or how to fix it.
wait fo you guys help..
解决方案
RMI is explained very well, in a nutshell but with code samples and good references, here:
http://en.wikipedia.org/wiki/Java_remote_method_invocation[^].
However, I would be very curious where such though could come from. Why won''t you try to implement a calculator using Large Hadron Collider or something equally impressive? :-)
—SA
i know it just that my excessive said i must use RMI for practice and learn..
do you know whats wrong at my server code ?