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
23.3k4 gold badges63 silver badges72 bronze badges
asked Jan 3, 2011 at 7:47
5
  • 1
    It is doable but not a good design . Commented Jan 3, 2011 at 7:49
  • @org.life.java: How do you know it's not a good design? Commented 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 say Commented 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 ... Commented 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 .... Commented Jan 3, 2011 at 8:16

2 Answers 2

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...
answered Jan 3, 2011 at 7:51
Sign up to request clarification or add additional context in comments.

1 Comment

You might want to add that this is called inter-process communication.
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.

answered Jan 3, 2011 at 9:44

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.