java inter-process communication

杀马特。学长 韩版系。学妹 提交于 2020-01-02 05:38:10

问题


is it possible to use run a java class in command line to run a certain class or function in a running swing?

such as , when java Test asd will setText a running swing Jlabel to asd


回答1:


The most straight forward way is to create an RMI method call.

It's built into java from the beginning, reasonably simple and lightweight.




回答2:


The two programs run in separate processes. You will need to create an interface between the processes (or as Matthew put it: implement inter-process communication). There are millions of ways to achieve this, just to name a few:

  • Create a file-based interface (Test will write into a file and JLabel will read that file)
  • Create a TCP/IP connection between the two
  • Create a HTTP connection between the two (JLabel may run a glassfish thread or something like that)
  • Create a JMS connection
  • Create an RMI method call
  • Create a Webservice (again with JLabel running glassfish)
  • Many more...


来源:https://stackoverflow.com/questions/4582809/java-inter-process-communication

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!