r/javahelp • • May 27 '19

Communication between 2 separately running java applications.

Just as the title implies, how can I share around some data from one java program to another running at the same time? I am trying using sockets but I am only able to establish a connection between a program and a local server but not sure how to connect the 2nd application to it. Edit : thanks everyone! I was using sockets previously so I needed to looking a simple chat example like you you suggested and was able to make 2 java classes one which was the client and the other server which is exactly what I needed!

28 Upvotes

12 comments sorted by

View all comments

12

u/User1539 May 27 '19

Have one application act as the server, and the other act as the client.

4

u/Berserker74 May 27 '19

Ans how do I do that exactly? Any guides? Thanks!

9

u/User1539 May 27 '19

If you want to use sockets, I recommend looking up a simple chat example, then instead of sending a string of text, send JSON. Then just decide which of your applications will be the server, and which will be client. It doesn't really matter which.