Further editing:
I browsed the web and came across this wonderful article, which may also affect your question: http://www.szegedi.org/articles/remotejars.html
In this case, most of what I wrote below does not matter, but I still leave it just in case.
Edit:
Well, I think I better understand your requirements. However, the requirements are complex, so let me tell you what I think you are trying to do, and then I will see what solutions you offer. I'm probably wrong, then we do it again.
Requirements:
Distributed caching mechanism for serving WebStart applications. Applications (.jars) are changed on a regular basis. They are self-sufficient. You want the local cache to be able to serve jar Webstart files received from the central server, storing them in memory. I do not understand your requirements for Exit.
Solutions?
What you are probably looking for is a web server that can host a webapp that will read updated application banks into memory and then serve them in the webstart launchpad. You will need to use a web server such as Jetty / Tomcat and write a simple webapp to run under it. Webapp will test the central server for application updates and make application banks accessible for webstart through the URLs it serves. Polling a central server probably makes more sense than a central server, which runs new applications on local servers for firewall and scalability reasons.
I do not know any ready-made webapps that do this, maybe one.
But, as I said, I probably still do not understand. Requirements: loved them.
I am going to make some assumptions in this answer based on your question. It looks like you want to cache "app.jar" from the remote machine throughout the life of "load.jar" on the local computer to allow isolating "load.jar" from changes to "app.jar" "during its lifetime. This seems like a good idea: I would expect that if you use URLClassLoader to cast "app.jar" into the space "load.jar", then an update in the middle of execution can lead to chaos.
It also sounds like you don’t want “load.jar” to make a copy of “app.jar” on disk - I think this is a reasonable goal: who wants old jar files to be scattered around on the machine? who wants to solve the problems associated with trying to write temporary files?
Given these goals, you need to find or implement a class loader that takes a snapshot of "app.jar" when "load.jar" first gets into the class inside it. It's not complicated: I had to do something similar in my One-JAR JarClassLoader, which loads Jar files from Jar files. During startup, it loads all found bytes into memory, and then resolves classes on demand using this storage. Although it is less efficient than lazy loading, it works quickly and stably and solves your problem.
Unfortunately, One-JAR does not allow you to cache network resources (or files) in this way. It uses delegation through a regular URL class loader, which makes it not caching your remote resources.
I suggest you take a look at the CVS repository: http://one-jar.cvs.sourceforge.net/viewvc/one-jar/one-jar/src/com/simontuffs/onejar/JarClassLoader.java?revision=1.58&view=markup
around line 678. Do not worry about the size of this class, its bunch of special cases for handling, as well as special cases.
If I had to create something from scratch, I would subclass URLClassLoader, redefine loadClass, getResource and findResource methods (see, for example, line 281, where One-JAR does this for its own requirements for inverting the loader class), insert byte caching by loading the entire "app.jar" into memory as a hashmap of a byte array indexed with class / resource keys (this is again a single-JAR), and then you will be cached in memory.
Hope this helps.
-. Simon