This is not about two JVM’s communicating with each other, this is about “joining” an existing running JVM, preventing the creation of an additional process.
We are deploying a control system that has a data collection component, a GUI operator interface, and a data logging component (in java).
Both the data logging component and the GUI make use of the data collection component. Normally there would be no issue, they both live in the same VM and can get updates through events or observer pattern. The problem is that the data logger must be run when the machine boots (linux) but the GUI only runs when the user logs in. If two instances of the data collection component are created (ie in two JVM’s) it causes issues with our comms monitoring which are beyond the scope of this question, but let’s just say there is a requirement that only one instance of the data collection component can be run.
Is there any way that one can instantiate a class in an existing, running VM? Would this class object be able to interact with live objects in the VM? What i would like to do is run the data logger as a daemon, creating one JVM, and then when the user logs on to the os, instantiate the GUI class in the running VM.
RMI, JMS, JMX, Sockets, Datagrams.
Yes.
The OS may prevent you from doing that unless the process is running as the user logged in. i.e. one user cannot display a GUI on the screen used by another user. If the OS allows you, there isn’t a problem.
Of course, you would normally run two JVMs, with one talking to the other (solving any security issues) as there is little advantage in having only one JVM.