2

Considering application_A on a machine_1 needs information about machine_2, provided by application_B (which is located on machine_2) and that both machines are in the same network, what would you guys suggest to be the easiest way of implementing the communication between the 2? (I was thinking simple socket connection).

Note: the information required is something in the lines of a few bytes, so nothing big.

CosminO
  • 5,018
  • 6
  • 28
  • 50
  • 1
    there are a [few ways, depends of...](http://stackoverflow.com/questions/6121990/pass-string-as-params-from-one-java-app-to-another) – mKorbel Sep 17 '12 at 10:05
  • 1
    Here you may find a simple and complete example: http://systembash.com/content/a-simple-java-tcp-server-and-tcp-client/ – PeterMmm Sep 17 '12 at 10:06

4 Answers4

4
  1. You can either use socket based communication or Java RMI.
  2. I would recommend Java RMI as its easier and saves you from handling raw socket communication.
  3. If you are familiar with Spring framework, then writing RMI application in spring is very easy. Check Exposing services using RMI (Heading 17.2)
Elon Than
  • 9,603
  • 4
  • 27
  • 37
Santosh
  • 17,667
  • 4
  • 54
  • 79
1

There are different ways to implement this but they all come down to one thing: communication over sockets.
If the information is only some bytes, implementing the sockets themselves is probably your best bet, if things start to get bigger, you might want to look into some middleware.

Minion91
  • 1,911
  • 12
  • 19
1

You can run a server program on Machine2 using ServerSocket and a client program in Machine1 can request for info.

basiljames
  • 4,777
  • 4
  • 24
  • 41
0

You can try web services. JAX-RS would be the simplest.

ACV
  • 9,964
  • 5
  • 76
  • 81