Java:类路径 JVM 上的多个资源中的哪一个? [英] Java: Which of multiple resources on classpath JVM takes?

查看:32
本文介绍了Java:类路径 JVM 上的多个资源中的哪一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在类路径上有多个同名文件(例如,我有多个 .jarlog4j.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 上的多个资源中的哪一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆