-4

I'm looking for a solution/suggestion to merge two different JVM into single JVM. Currently I have two different web applications running on two different JVM. Say web_application1 has app1_Jvm & web_application2 has app2_Jvm.

Now I need to utilize only one JVM say app_Jvm for both web_application1 & web_application2.

Thanks!!

ebullient
  • 1,250
  • 7
  • 16

2 Answers2

2

Assuming that the two applications are in their own .war or .ear files or similar that have different names, they can be placed next to each other in the deployment directory, and the application server will expand and start both of them, each under their own application root, within the same JVM. This is standard behavior for web application servers.

Jonah Benton
  • 3,598
  • 1
  • 16
  • 27
  • 1
    For Tomcat, the two wars will be auto-detected in the deployment directory: http://stackoverflow.com/questions/14972494/how-to-deploy-war-files-to-tomcat-manually. For WebSphere Liberty, the two wars will be auto-detected in the dropins directory, or can be explicitly configured in server.xml (which may be necessary to add the use of shared libraries, e.g.): https://www.ibm.com/support/knowledgecenter/SSD28V_8.5.5/com.ibm.websphere.wlp.core.doc/ae/twlp_dep.html – ebullient Sep 12 '16 at 12:58
-1

I believe that if you were to have each of your main application classes implement Runnable you could run both inside a single main method.

Check out Threads which gives a perfect example of how to do it. All that's left to do is in your main you would simply create the two threads that contain the application objects and call the start() method for each thread which in turn calls the run() method inside of each application object.

class App1 implements Runnable {
     App1() {
         //your constructor
     }

     //all other methods ...


     public void run() {
         // this will be the main method for App1
          . . .
     }
 }

class App2 implements Runnable {
     App2() {
         //your constructor
     }

     //all other methods ...


     public void run() {
         // this will be the main method for App2
          . . .
     }
 }

//your new main method
public static void main(String[] args) 
{
     //create the first application object
     App1 application1 = new App1();
     //create the second application object
     App2 application2 = new App2();
     //call their main methods run()
     new Thread(application1).start();
     new Thread(application2).start();
}
RAZ_Muh_Taz
  • 4,059
  • 1
  • 13
  • 26
  • While this works for core java applications, the OP appears to be asking about Websphere which has it's own way of deploying multiple applications. – Peter Lawrey Sep 10 '16 at 07:44