如何在Java桌面应用程序中引用exe外部的jar?
我安装了一个 Java 应用程序。使用 Launch4J 将 jar 捆绑到 .exe 文件中。现在我想为此应用程序创建一个补丁。
如果我创建另一个仅包含更新文件的 jar,我如何在原始代码中引用它?
I have a Java application installed. The jar is bundled into an .exe file using Launch4J. Now I want to create a patch for this application.
If I create another jar containing only updated files, how can I refer it in the original code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是 J2SE 附带的 Java Web Start 启动技术的优势之一。只需更新服务器上的 Jar 以及下次应用程序即可。推出后,将会更新。
可以根据您的用例进行更新,配置为在启动之前或之后延迟或急切地完成更新,甚至可以使用 JNLP API 的 DownloadService。
“不幸的是”,JWS 可在 Windows、.. 和 Mac. 以及 *nix 上运行 - 所以您可能必须扩展您的视野。
顺便说一句 - 我不知道如何对 Launch4J 做同样的事情,但是,这确实是一个错误的问题。我的目标是提供正确问题的答案,即“如何部署和更新 Java 富客户端?”。 ;)
This is one of the strengths of the Java Web Start launch technology that comes with the J2SE. Simply update the Jar on the server, and the next time the app. launches, it will be updated.
The update can be honed for your use-case, configured to be done lazily or eagerly, before or after launch, or even programatically controlled using the JNLP API's DownloadService.
'Unfortunately', JWS works on Windows, ..and Mac., and *nix - so you may have to expand your horizons.
BTW - I have no idea how to do the same with Launch4J, but then, that is really the wrong question. I aim to provide an answer to the right question, which is "How do I deploy & update a Java rich client?". ;)
我从未使用过 Launch4J,但我认为您应该尝试影响类路径。 JRE 始终从类路径加载类。从这个角度来看,jar 没有附加值,只是充当 *.class 文件和资源的容器。
现在,如果您成功配置工具来执行以下操作:
类路径 = C:\Temp\my_patch_path;$your_current_classpath
然后将更改的文件放入 C:\Temp\my_patch_path 就足够了(当然保留包结构)。在这种情况下,JRE 将首先加载您的类。
希望这对
马克有帮助
I've never worked with Launch4J, however I think you should try to affect the classpath. JRE always loads the classes from the classpath. From this point of view, jars have no added value and just serve as a containers for your *.class files and resources.
Now, if you succeed to configure your tool to do something like:
classpath = C:\Temp\my_patch_path;$your_current_classpath
then its enough to put your changed files into C:\Temp\my_patch_path (of course preserving the package structure). JRE will load your classes first in this case.
Hope, this helps
Mark
如果不更改 exe 的内容,可能无法执行此操作。
It is might not be possible to do this without changing the contents of the exe.