java - 在运行时交换正在运行的 jar

标签 java file plugins jar locking

我正在构建一个更新系统,其中我需要能够在运行时替换正在运行的应用程序 jar 的引用 jar。但是,当我尝试在 jar 上执行文件实用程序功能(例如“setLastModified”)时,我在 Windows 上遇到了文件锁定问题。

经过一番谷歌搜索后,我发现了这个片段......

What I found in my research is that the standard ClassLoader implementation never closes a jar file once it has been opened. It also only loads resources from the jar file as needed. So at any particular time, there may be Classes in the jar file that have not been loaded into memory. Obviously, if you delete the jar file out from under the ClassLoader, and it tries to find a resource in the missing file, you're going to get an IOException at the very least.

是否有人引用了有关执行此操作或解决此问题的信息?

谢谢。

最佳答案

类/库热插拔的解决方案有很多:

这取决于你想做什么。

关于java - 在运行时交换正在运行的 jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3621505/

相关文章:

Java Applet 下载文件

java - 当 JAVA 应用程序连接到 Docker 中的 Postgres 时,未加载 JDBC 驱动程序类

delphi - 减少exe文件

android - phonegap-plugin-facebook-connect : no callback function after FB. 登录

c# - 使用 C# 制作 SQL Server 插件

java - 创建粗体单元格边框线 JTable

java - 对等价类的元素进行分组的数据结构

javascript - 使用脚本设置文件上传内容

c - 为什么插入的用户值与文件值不匹配?

java - 无法解决使用 eclipse luna 和 equinox 进行编译的基本障碍(新手)