I'm currently working on a requirement for a desktop application - using Java

If for some reason the GUI crashes, it shouldn't affect the background process. Once the GUI is restarted - the execution status along with the log messages should be given back to GUI.

Desktop application is built for both windows & ubuntu 12.04.

As per my knowledge in Java, this could be achieved using Sockets. Keeping GUI as client, and executing background code in a Server.( But again i'm still trying to understand how the server stays alive if the GUI crashes, - I mean if server is started from the GUI instance @ any point, and if the GUI crashes, the server is dead too, bcz it still belongs to the same JVM instance, right ? )

The question really comes down to - how to start a server(tcp) in a new process from the gui instance. Can someone throw some light on - how to implement this requirement?

  • 1
    Just start a new process, what's the problem? Or make the user launch 2 different things. Also, I'm not really sure why your stakeholders think that GUI crashes are more frequent than background process crashes. Only reason I know about is problems with the graphics environment changing during the lifetime of the program.
    – Ordous
    Sep 16, 2014 at 10:36
  • I don't think launching 2 different things is an option for me, bcz the background process starts when the user clicks on the 'start' button in the GUI. Starting a new process isn't a problem, but my concern is how to run the server(tcp) on a new process in Java when the user clicks the 'start' button in UI.
    – Jitendar
    Sep 16, 2014 at 11:26
  • Launching a new process is easy, SO has quite a few answers for that. Making it portable isn't (though supporting just Ubuntu and Win is fine)
    – Ordous
    Sep 16, 2014 at 11:31
  • yes RMI is better to use .Sockets is very old and suitable best in Networking Applications.
    – katanor
    Sep 18, 2014 at 10:33

2 Answers 2


Sockets, RMI, Protocol Buffers, Thrift, CORBA, DCOM, ... the number of RPC systems is long and extensive. They all have a similar goal though: provide a system to allow a client process and another server process talk to each other.

Today the possible best practice is to use a standard communication system, one where you can change the client to a different technology and the server will not need any modification. The system used by a lot of people is web services. Its still another form of remote communication, but if you implement the server using it, you'll be able to write a web-based client very easily, or open your server to other clients using a standard API.

If you need raw speed though, a socket is best, but its low-level. You'll have to make the protocol (ie the messages) you send yourself. I never found that to be a problem TBH, but many people prefer a framework that does that for you - protocol buffers can do this, or you can go even higher level and use something like RMI which will tie you into Java and will make it slightly easier.


Your problem can be solved if you use RMI in java.

RMI is Remote Method Invocation.

In this what you can do is , you can create two applications.one for GUI and another Server(where your actual process(functions) is existed). GUI can communicate with server via method calling with parameter pacing if necessary.But both application independent from each other. For your case this will work. Because if GUI(client) crash nothing happen to Server since it is independent from client execution. once you restart the client you can find the server and continue the works. But in case if server crashed then you have to restart both client and server. These application can be run in same JVM or separate JVMs . Anyway you have to use IP addresses to configure communication. I can give you small executable app(both apps client and server) if you want.


  • Thanks for the reply. I was thinking RMI is outdated, is it still used ?
    – Jitendar
    Sep 18, 2014 at 7:20
  • As long as java support it (for RMI) can be used. reason I suggested RMI is , it is the tool I used to solved a same type of problem in LAN environment.
    – lasa
    Sep 18, 2014 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.