开发者

Java: Load class while jar-file is updated

My Java program loads classes dynamically at runtime. All开发者_如何学运维 classes are located in the same jar.

After deploying a new jar file, I sometimes get errors while the jar file is copying (NoClassDefFoundError etc.). This goes away the next time I run the program of course. Is there a way to preload classes so that my program is not affected when updating the jar?

I guess I could create instances of all classes and then clone() them, but perhaps there's a better way?


Even if you load all the classes, you may still get errors from resources.

I suggest deploying to a different location if at all possible. Alternatively, if you can manager the class loading, copy the jar to a temporary file (which is automatically done for http URLs, for instance) or into memory.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜