2

Possible Duplicate:
Communication between two separate Java desktop applications

I have two java programs running on the same client, How can I do that first program passes some parameters or dates to the second program?

Community
  • 1
  • 1
Dorr
  • 133
  • 1
  • 4
  • 8

4 Answers4

2

It depends how would you like to communicate those 2 programs:

  • If you need only inter-process semaphores, create a file somewhere in /tmp and lock it.

  • If you need only inter-process synchronous messaging (remote procedure call), RMI should be easiest.

  • If you need asynchronous interprocess messaging, JMS should be easiest.

  • If you need inter-process shared memory, use mapped files.

  • If you need all the above, Terracotta (http://www.terracotta.org/ ) is the easiest way: Java programs on different JVMs on the same or even different computers see each other as if they were executed inside one JVM on one machine. Splitting one program into a few doesn't even require any code changes - it's enough to write an XML config file.

iirekm
  • 8,890
  • 5
  • 36
  • 46
0

You need a listener and a client.

You can do this with sockets or RMI or any other protocol that you choose.

duffymo
  • 305,152
  • 44
  • 369
  • 561
0

Depending on your requirements, Java Messaging Service, Jetlang or JavaSpaces might be appropriate.

Joseph Weissman
  • 5,697
  • 5
  • 46
  • 75
  • java.util.concurrent is for threads inside on program only - it doesn't support Inter-Process Communication. – iirekm Oct 13 '10 at 17:26
0

Assuming you mean these programs are running in different JVM's you would need to use Java Messaging Service, JavaSpaces, or god-forbid CORBA. JMS, as do the others, has overhead in that you need a JMS server such as activemq but otherwise is not that scary and very powerful. If you want to use java.util.concurrent or JetLang(I think) you will have to get the two programs running under the same JVM. Can you launch the one program from the other such that they share the same JVM memory space?

crowmagnumb
  • 6,621
  • 9
  • 33
  • 42