如何将新的 jar 文件添加到服务器中现有已部署的 jar

How to add new jar file to existing deployed jar in server

我在服务器上 运行 有一个 RMI 应用程序。现在我想将外部 jar 文件添加到现有已部署的 jar。

注意:它不是网络应用程序。

比如我这里提到的jar目录

MyApplication.jar

.class路径有

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
  <classpathentry kind="src" path="src"/>
  <classpathentry kind="lib" path="lib/test.jar"/>
  <classpathentry kind="lib" path="lib/test1.jar"/>
  <classpathentry kind="output" path="classes"/>
</classpath> 

现在我想将 test2.jar 添加到 MyApplication.jar 中的 lib 文件夹并更新 .classpath 文件。

可以添加吗?

如果您不能使用 JRebel then you will probably have to try to write your own class loader to achieve this. There are many pitfalls. See this answer and this question 一些指针。