• Post Reply Bookmark Topic Watch Topic
  • New Topic

Two different Java applications interaction  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two different Java applications interaction



How two different consoles based desktop Java applications running on same system/machine can interact to each other.

Is any one successfully done this type of programming?
If yes please share the piece of code and steps, which used for it.

Requirement -

We have two console-based application running on same machine. We want that when first application will finish its job it should inform to second application about job status.

:
 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the requirement is simple as stated above, the simplest approach would be creating a status file in a shared location on the system. The second application can keep on polling for this file.
 
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Java Cowboy
Sheriff
Posts: 16079
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
leo sks, welcome on JavaRanch. Please check your private messages. You can see them by clicking My Private Messages.
 
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sockets would be another possibility.
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sharing a file and polling it is simple in the sense that it uses file operations, which are something most Java programmers know about. However, there are subtleties to achieving reliable operation. Also, polling a file is quite a heavyweight operation, so you'd either have to accept using quite a lot of the machine's power for this, or polling infrequently and getting slow response.

If the job status information is all you will ever transfer, and it is simple, then the suggestion of using plain sockets is a good one. Sockets use very little of the machine's resources when inactive, but they also respond very quickly to data, when it arrives.

If the job status information is complicated, or you may later extend the application to exchange more types of information, it may be worth using something more capable, from the start. You could consider Web Services, CORBA, RMI etc.
 
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the Sun Networking Tutorial for a great jump start on the Sockets approach. The All About Sockets section has good sample programs.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!