gpt4 book ai didi

Java 类路径,Unix 上的 Weblogic 中不带 .jar 扩展名的 jar 文件

转载 作者:行者123 更新时间:2023-12-02 08:26:11 25 4
gpt4 key购买 nike

如果我将一个名为 libA.jar 的文件放在类路径文件夹中,并将旧文件重命名为:

libA.jar.old

类加载器会加载类吗?

我在 Solaris 8 上使用 weblogic。

谢谢!

乌多

最佳答案

没有。

如果您使用的是 Java 5 或更早版本,则必须显式命名要加载的所有类和 jar 文件。显然,由于旧的 libA.jar.old 未命名,因此不会加载它。

如果您使用 Java 6,情况会有所不同,因为那里存在通配符匹配的概念。

仍然不会加载非 jar 文件。信息取自official site 。引用:

Class path entries can contain the basename wildcard character *, which is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR. For example, the class path entry foo/* specifies all JAR files in the directory named foo.

A classpath entry consisting simply of * expands to a list of all the jar files in the current directory. A class path entry that contains * will not match class files. To match both classes and JAR files in a single directory foo, use either foo;foo/* or foo/*;foo. The order chosen determines whether the classes and resources in foo are loaded before JAR files in foo, or vice versa.

关于Java 类路径,Unix 上的 Weblogic 中不带 .jar 扩展名的 jar 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4488360/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com