Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Many Apps, One JVM  RSS feed

 
Mae Cerico
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all. How can I efficiently implement running 2 or more different applications in the same JVM? Can class loaders solve this? Is this really efficient? Btw, I have a main application loader which is supposed to load/run the different applications. Thanks.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mae Cerico:
Hi all. How can I efficiently implement running 2 or more different applications in the same JVM? Can class loaders solve this? Is this really efficient?
Yes, classloaders can solve this; classes loaded by different classloaders are considered distinct and are effectively isolated from each other (although they can still access each other using reflection). There are no efficiency issues. It's not an obscure problem, every application server is doing this to keep their web-applications separate. You may even be able to nick code from any of the open source servlet containers (Tomcat, Jo!, Jetty...)
If you need to securely enforce the mutual isolation of the applications, you can use the Java security mechanism to achieve this. There is a small performance degradation associated with Java security (I cannot quantify this, but the checks performed on many system calls do incur the inevitable performance penalty). This is not a task for the faint of heart however.
The issue is not really thread-related; you're likely to get a better response on the Java in General (Advanced) forum. I'll move this thread there.
- Peter
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!