简体   繁体   English

java进程间通信

[英]java inter-process communication

is it possible to use run a java class in command line to run a certain class or function in a running swing? 是否可以在命令行中运行java类来在正在运行的swing中运行某个类或函数?

such as , when java Test asd will setText a running swing Jlabel to asd 例如,当java Test asd将setText运行一个Jlabel运行到asd时

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 ). 您需要在进程之间创建一个接口(或者像Matthew所说的那样:实现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) 创建基于文件的界面(Test将写入文件,JLabel将读取该文件)
  • Create a TCP/IP connection between the two 在两者之间创建TCP / IP连接
  • Create a HTTP connection between the two (JLabel may run a glassfish thread or something like that) 在两者之间创建HTTP连接(JLabel可能运行glassfish线程或类似的东西)
  • Create a JMS connection 创建JMS连接
  • Create an RMI method call 创建RMI方法调用
  • Create a Webservice (again with JLabel running glassfish) 创建Web服务(再次使用JLabel运行glassfish)
  • Many more... 还有很多...

The most straight forward way is to create an RMI method call. 最直接的方法是创建一个RMI方法调用。

It's built into java from the beginning, reasonably simple and lightweight. 它从一开始就内置于java中,相当简单轻巧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM