java计算器rmi,如何使用RMI创建计算器?

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 ?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值