问题描述
如果我在类路径上有多个同名文件(例如,我有多个 .jar 和 log4j.properties),JVM 遵循什么规则来选择一个?
If I have multiple files of the same name on classpath (e.g. I have multiple .jar with log4j.properties), what are the rules JVM follows to chose one?
推荐答案
使用-classpath选项指定资源(即通常是jar文件)的顺序来指定.类路径上较早"的资源优先于在它们之后指定的资源.这也可以在您的应用程序的清单文件中设置,然后您不需要提供 -classpath 选项.您可能需要查看这些文章,了解如何使用清单文件.
It is specified by the order in which the resources (i.e. usually jar files) are specified using -classpath option. Resources 'earlier' on the classpath take precedence over resources that are specified after them. This can be also set in the manifest file of your application and then you don't need to provide -classpath option. You may want to check these articles on how to work with manifest files.
可以在这里,JAR-class-path Classes部分描述了JAR文件搜索的逻辑.
The exhaustive description of "how classes are found" can be found here, where the section on JAR-class-path Classes describes the logic of JAR-files searching.
这篇关于Java:类路径 JVM 上的多个资源中的哪一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)