Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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
Posts: 16084
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: 42974
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)
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!