java 如何使用 Netbeans 构建这个 RMI 项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17086072/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to build this RMI project using Netbeans?
提问by Ryzal Yusoff
I have been following this step by step tutorial about RMI: http://www.javacamp.org/moreclasses/rmi/rmi.html, and already succeeded in compiling and running this project by using command prompt as what the tutorial has taught here: http://www.javacamp.org/moreclasses/rmi/rmi6.html.
我一直在关注这个关于 RMI 的分步教程:http: //www.javacamp.org/moreclasses/rmi/rmi.html,并且已经通过使用命令提示符成功地编译和运行了这个项目,就像教程在这里教的那样:http: //www.javacamp.org/moreclasses/rmi/rmi6.html。
But now I am wondering, how is it if I want to create this project using Netbeans? So that I can create GUI for this project and just run it from the Netbeans IDE. Up until now, I have tried the multiple numbers of way to create it on Netbeans, but each time, the project failed to be run. Please help, as I have spent about 4 days already and not yet find any solution or tutorial that can guide me through.
但是现在我想知道,如果我想使用 Netbeans 创建这个项目怎么办?这样我就可以为这个项目创建 GUI 并从 Netbeans IDE 运行它。到目前为止,我尝试了多种方法在Netbeans上创建它,但每次都无法运行该项目。请帮忙,因为我已经花了大约 4 天的时间,还没有找到任何可以指导我完成的解决方案或教程。
This is the screenshot that I got after trying to run it from Netbeans:
这是我尝试从 Netbeans 运行后得到的屏幕截图:
To be clear, what I am trying to do is "to create a swing client for the RMI application that create and run the RMI invocation in Netbeans instead of command line"
明确地说,我想要做的是“为 RMI 应用程序创建一个 Swing 客户端,在 Netbeans 而不是命令行中创建和运行 RMI 调用”
回答by Ryzal Yusoff
I have finally found the way to do this. What i need to do is start the RMIRegistry first before i run the Server. Unlike in the command prompt where i have to typr "start rmiregistry", i just have to put this line in my Server.java code in the Netbeans to start thr RMIregistry : " LocateRegistry.createRegistry(1099);" where 1099 being the port number.
我终于找到了做到这一点的方法。我需要做的是在运行服务器之前先启动 RMIRegistry。与在命令提示符中我必须输入“启动 rmiregistry”不同,我只需要将此行放在 Netbeans 中的 Server.java 代码中即可启动 thr RMIregistry:“LocateRegistry.createRegistry(1099);” 其中 1099 是端口号。
回答by samsons17
actually, you can use both LocateRegistry.createRegistry() or just type rmiregistry in the command prompt to start the rmiregistry whenever u want to use it for netbeans project
实际上,您可以同时使用 LocateRegistry.createRegistry() 或仅在命令提示符中键入 rmiregistry 来启动 rmiregistry,只要您想将其用于 netbeans 项目
回答by user207421
'Connection refused' means in this case that there was no Registry running at the indicate IP:port. So fix that, or fix the IP:port.
在这种情况下,“连接被拒绝”意味着没有在指定 IP:port 上运行的注册表。所以修复它,或修复IP:端口。