Java 服务器代码将数据传递给正在运行的 java 程序
有没有办法可以将数据从 Java 服务器代码传递到已经运行的 Java 程序?
我需要实时传输数据,并且我无法集成这两个程序,因为它们使用不同的编译器。
有什么想法吗? 谢谢
** 添加信息 **
我希望通过互联网控制机器人。我有与客户端通信的服务器代码,以及用独特类型的 Java 代码(LeJOS,如果有人熟悉的话)编码的程序。我需要从服务器端将数据实时传递到 PC LeJOS 程序。因此,LeJOS PC 程序在运行时必须能够从服务器代码接收一些数据。
这可能吗?需要澄清的是,服务器代码和 LeJOS PC 程序将在同一台机器上运行。
另一种可能性是将服务器代码和LeJOS PC程序集成到一起,以便LeJOS PC程序直接从服务器代码运行。可以这样做吗?
谢谢!
Is there a way I can pass data, from Java server code, to a Java program which is already running?
I need to transfer data in real time, and I cannot integrate the two programs as they use a different compiler.
Any ideas?
Thanks
** ADDED INFO **
I am looking to control a robot over the internet. I have the server code which communicates with the client, and a program coded in a unique type of Java code (LeJOS if anyone is familiar with it). From the server side I need to pass data to the PC LeJOS Program in real time. Hence, the LeJOS PC program must be able to receive some data from the server code, whilst it is running.
Is this possible? To clarify, both the server code and the LeJOS PC Program will be running on the same machine.
Another possibility could be to integrate the server code and LeJOS PC program into one, so that the LeJOS PC program is run directly from the server code. Would it be possible to do this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,这是一个相当广泛的问题,它实际上取决于您的应用程序的限制。基本上你必须通过一些中间渠道来转移它。
选项:
...以及更复杂的方法:
如果您需要更具体的答案,您必须告诉我们更多地了解:
Hm, that's a pretty broad question, and it really depends on what the restrictions are on your app. Basically you're doing to have to transfer it through some intermediary channel.
Options:
...and going to much more complicated methods:
If you need a more specific answer, you'll have to tell us more about:
让客户端通过套接字连接到服务器。它们是否在同一台机器上运行并不重要。这几乎就是 Java 中“ipc”的方式,如果你想扩展对网络的控制,无论如何你都必须去那里。
您可以双向发送数据,因此取决于您想要如何使用它。实现协议的最简单方法是文本,这样很容易调试。如果您可以使其面向请求/响应,那么事情也会变得更简单。
这是 Java 网络 IO 的基本教程。 http://docs.oracle.com/javase/tutorial/networking/sockets /index.html
祝你好运。
Have the client connect to the server via a socket. It doesn't matter if they're both running on the same machine or not. That is pretty much they way you do 'ipc' in Java, and if you want to extend the control over the network you'll have to go there anyway.
You can send data bidirectionally, so its up to you how you want to use that. The simplest way to implement your protocol is something textual, that way its easy to debug. If you can make it request/response oriented then that makes things simpler too.
Here's a basic tutorial for network IO in Java. http://docs.oracle.com/javase/tutorial/networking/sockets/index.html
Good luck.