求远程打印程序!!!急!

kesney 2003-03-06 12:03:46
老师留了作业,用RMI远程打印:

打印服务器生成打印存根和骨架,客户端进行调用。

...全文
46 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
小点哥 2003-03-13
  • 打赏
  • 举报
回复
在线等待啊。。我也需要答案!!!!!!!
好想上面的实现不了啊。。。
把代码全部奉献出来!!!

多谢!
小点哥 2003-03-13
  • 打赏
  • 举报
回复
接口RemotePrinter
如何写啊??

拜托了!!
小点哥 2003-03-13
  • 打赏
  • 举报
回复
hwo toInterface RemotePrinter
rocqin 2003-03-12
  • 打赏
  • 举报
回复
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.util.*;
import javax.swing.*;



public class ServerPrinter extends UnicastRemoteObject implements RemotePrinter{
private static int CallTimes=0;

public ServerPrinter() throws RemoteException{super();}

public void GoPrint() throws RemoteException{
CallTimes+=1;
System.out.println("Go Print for "+ CallTimes +" times!");
//PrintSample ps = new PrintSample();
//ps.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//ps.pack();
//ps.setVisible(true);
}

public static void main(String[] args) {
try{
System.out.println("Prepare to Start Serving! Please Wait...");
ServerPrinter printer = new ServerPrinter();
System.out.println("Print Server Ready! Start Serving...");

/*NEW Implementation
* Create a registry and bind stub in registry.
*/
LocateRegistry.createRegistry(2002);
Registry registry = LocateRegistry.getRegistry(2002);
registry.rebind("FirstRemote", printer);

/*OLD Implementation 这种方法需要外部使用rmiregistry命令
String name= System.getProperty("Printer Name","FirstRemote");
Naming.rebind(name,printer);
*/
System.out.println("Server open and ready for customers!!!");
}
catch(Exception e){
System.err.println(e.toString());
}
}
}

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧