问题描述
||
我正在使用Java RMI编写客户端-服务器应用程序。
现在,我的问题是我有多个客户端和一个服务器,要查看一些通信,客户端和服务器上都具有System.out.println语句(SOP),但是我只能在一个控制台上看到所有输出,有没有办法分别查看?
为了进一步阐明这一点,让我举一个简单的例子,
**Server**
void callServer(){
System.out.println(\"Server is called\");
}
**Client**
void callClient(){
System.out.println(\"Client is called\");
server.callServer();
}
**Simulator**
main(){
//create RegistryServer
//create server instance
//create client instance
System.out.println(\"Sim Started\");
client.callClient();
}
Sim的输出
Sim开始
客户被称为
服务器被称为
期望的输出
Sim Console:
Sim Started
Client Console:
Client is called
Server Console:
Server is called
可能吗?
解决方法
您是否将客户端和服务器分别放置在不同的应用程序中,还是同时运行它们?如果将它们分开,则可以在单独的终端中分别运行它们,并且写到标准输出将把每个应用程序的输出打印到其自己的终端上。