Reputation: 308
I am having a main class called ProccesA, after I run it I am starting another main class (when ProccesA is still running for his own) and I wish to get the instance of ProccesA to use it in my class, can some one direct me how to do that ?
Upvotes: 4
Views: 845
Reputation: 5710
Both processes execute in different JVMs, and so use different class loaders. You can't access them directly.
You could however, use RMI to expose the required classes in one of the processes, and access them that way.
Upvotes: 1
Reputation: 727037
Processes are not like threads: you cannot get access to instances of classes running in different processes, because they are in a different address space. You need to use interprocess communication facilities to communicate to other processes.
Upvotes: 3