0

is it possible to do such a thing like to get some static data in one java process from another:

I have 2 java applications.

Application 1

public static String hello;

public static void string main(String[] args) {
  hello = "hello";
}

Application 2

public static void string main(String[] args) {
  String hello = someHowTakeInitializedHelloPropertyFromApplication1()
}
victor.chicu
  • 106
  • 1
  • 2
  • 14

1 Answers1

1

You cannot access objects in the memory space of another process running a JVM. If you need access to any data from another process, make the class that represents that data serializable, and provide an API in the other process to make serialized object available to other processes.

This Q&A discusses options for sharing information across JVMs. For your situation when a very small amount of information needs to be shared, coding a managed bean using Java Management Extensions may be an expedient option.

Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
  • Yes, the problem that I want to read the object from another process that is not serializable and I cannot change the implementation of this object. Why i'm trying to do this crazy things because one process instantiate the list of objects taking information from jar files through reflection. The second process is started frequently but it doing the same operation of information loading. (Is just the question of optimization) Good if it possible things I can just to replace loading method procedure in second process what can load already instantiated objects from another process. – victor.chicu Sep 08 '17 at 14:10