4

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

Sanjay T. Sharma
  • 22,857
  • 4
  • 59
  • 71
wizztjh
  • 6,979
  • 6
  • 58
  • 92
  • 1
    It is doable but not a good design . – jmj Jan 03 '11 at 07:49
  • @org.life.java: How do you know it's not a good design? – Lukas Eder Jan 03 '11 at 07:52
  • @Lukas Eder He tries to communicate between two process, that can be done by using some other technique also, what do you say – jmj Jan 03 '11 at 07:57
  • It is a very sux idea , but I am lack of option because I am doing my final year project and my lecturer want me to use a proprietary software "vitamin d video" that do human detection and able to run a command line when detect one. So I need to show human activity in my java swing ... – wizztjh Jan 03 '11 at 08:13
  • I don't have the hacking skill to understand the assembly code , so i just go with this method .... – wizztjh Jan 03 '11 at 08:16

2 Answers2

9

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...
Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
3

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

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

KarlP
  • 5,149
  • 2
  • 28
  • 41