Multiple Applications Running On One JVM

Multiple Applications Running On One JVM

Question:
I want to know how to run more than one application under one VM. Iam developing some Java servers, but I don’t want 10 JVMs running whenonly one is necessary. Is there a solution to this?

Answer:
One approach at your disposal is to create a server process whose onlyjob is to load Java classes and execute their main() methods in aseparate thread.

The problem with doing this is that you do not benefit from the separation of address spaces and process contexts that you get from using separate JVMs. If one application thread terminates the application with an errant System.exit(0) or throws a fatal RuntimeException, all your applications will die. In addition, each application will share the same ClassLoader unless you explicitly force each to use a different ClassLoader.

You will want to use a different ClassLoader for each application, otherwise you will runinto problems where applications sharing global state in the form of static variables. Any attempt to share a single JVM between multiple Java applications will in effect lead to implementing your own application server. You could investigate the possibility of usingon of the many available application servers or possibly restructure your applications in the form of servlets.

Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular