1

I am writing a program that starts another java process which runs certain code. Is there any way I can "talk" to that process to call methods of the running class(es)?

asked Aug 20, 2009 at 16:22

6 Answers 6

7

You're going to have to use some form of remoting. That could be:

  • RMI;
  • Web Services (JAX-WS, Spring Web Services, etc);
  • Sockets;
  • Embedded Web container;
  • etc.
answered Aug 20, 2009 at 16:25
Sign up to request clarification or add additional context in comments.

Comments

1

They will be able to communicate via pipes or sockets. You either create your own communication protocol over it, or use something like RMI.

answered Aug 20, 2009 at 16:27

Comments

0

RMI is a simple Java remoting technology. Of itself it doesn't address issues that tend to surface when you go for large-scale client and server scenarios, such as failover in the event of errors.

Hence the usual pattern when requiring something a bit stronges is to use some "App Server" kind of technology on the server side. You can knock up remotely accessible services quite quickly using frameworks such as EJB 3 or Spring, or you can use technlogies such as JMS.

My recomendation would be to bite the bullet and go beyond RMI immediately, these days the maturity of the App Servers and frameworks, and the availability of low cost and free App Servers makes the cost of entry pretty low.

answered Aug 20, 2009 at 16:31

Comments

0

Another approach is Jini.

answered Aug 20, 2009 at 19:26

Comments

0

There's a whole class of solutions referred to as IPC, Inter-Process Communication. These range from shared memory and pipes, to network communication and remote procedure frameworks. In java you have a variety of solutions to each of these. If you're familiar with networks already, you can pass messages that way, otherwise you might want to setup asynchronous message queues or pipes, you'll likely find shared memory being prone to bugs, and remote procedures like JINI being too complicated to setup and maintain.

answered Aug 20, 2009 at 21:35

Comments

0

One more solution, albeit not that trivial, is JMS. If the nature of the communication is mostly to pass information or small objects, this could be useful.

answered Aug 20, 2009 at 21:43

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.