Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java inter-process communication

Tags:

java

swing

ipc

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

like image 343
wizztjh Avatar asked Dec 17 '22 18:12

wizztjh


2 Answers

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...
like image 189
Lukas Eder Avatar answered Dec 19 '22 06:12

Lukas Eder


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

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

like image 20
KarlP Avatar answered Dec 19 '22 06:12

KarlP