The best known way to do this is to open ServerSocket when the first application is launched in a well-known port.
If ServerSocket is not loading, it is possible because the instance is already running.
In this case, you can open Socket and start communicating your orders between both instances.
But you can also use much more complex solutions such as Jini or JGroups.
source share