spinker
spinker

Reputation: 308

Access an instance in another running Java program?

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

Answers (2)

Rajesh J Advani
Rajesh J Advani

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

Sergey Kalinichenko
Sergey Kalinichenko

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

Related Questions