How to load classes from jar file in-memory stream

天大地大妈咪最大 提交于 2019-12-20 03:14:52

问题


I'm building a Java application that has parts that require daily update. I want to download frequently updated parts as small jar file from my server to memory. I'm downloading the jar file as byte stream and not using URLClassloader.

  1. How can I make the classes in the jar file to be available to the system class loader from my custom class loader?

  2. How can I make sure that the download jar file and loaded classes are never cached or written to disk.


回答1:


You can have a custom class loader load from memory. You can force the system loader, load specified classes from memory. However, you can't change the default system loader to read from memory on the fly.



来源:https://stackoverflow.com/questions/9964076/how-to-load-classes-from-jar-file-in-memory-stream

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!