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
-
1It is doable but not a good design .Jigar Joshi– Jigar Joshi2011年01月03日 07:49:17 +00:00Commented Jan 3, 2011 at 7:49
-
@org.life.java: How do you know it's not a good design?Lukas Eder– Lukas Eder2011年01月03日 07:52:42 +00:00Commented Jan 3, 2011 at 7:52
-
@Lukas Eder He tries to communicate between two process, that can be done by using some other technique also, what do you sayJigar Joshi– Jigar Joshi2011年01月03日 07:57:11 +00:00Commented Jan 3, 2011 at 7: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– wizztjh2011年01月03日 08:13:43 +00:00Commented Jan 3, 2011 at 8:13
-
I don't have the hacking skill to understand the assembly code , so i just go with this method ....wizztjh– wizztjh2011年01月03日 08:16:52 +00:00Commented Jan 3, 2011 at 8:16
2 Answers 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...
answered Jan 3, 2011 at 7:51
Lukas Eder
224k138 gold badges731 silver badges1.6k bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Matthew Flaschen
You might want to add that this is called inter-process communication.
The most straight forward way is to create an RMI method call.
It's built into java from the beginning, reasonably simple and lightweight.
answered Jan 3, 2011 at 9:44
KarlP
5,2212 gold badges30 silver badges41 bronze badges
Comments
lang-java