CosminO
CosminO

Reputation: 5226

Java communication between 2 applications

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.

Upvotes: 2

Views: 6325

Answers (4)

Santosh
Santosh

Reputation: 17893

  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)

Upvotes: 4

ACV
ACV

Reputation: 10562

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

Upvotes: 0

basiljames
basiljames

Reputation: 4847

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

Upvotes: 1

Minion91
Minion91

Reputation: 1929

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.

Upvotes: 1

Related Questions