在当前发行版中,可以在 JVM 系统类路径中找到添加到 domain.xml(应用服务器配置文件)的 classpath-prefix、server-classpath 和 classpath-suffix 属性中的 JAR 和目录条目。依赖于这种行为的应用程序可能会使用类 java.lang.ClassLoader 中的以下方法,访问 JVM 系统类路径中的类或其他资源:
getSystemClassLoader()
getSystemResource()
getSystemResourceAsStream()
getSystemResources
在下一个主要发行版中,添加到 classpath-prefix、server-classpath 和 classpath-suffix 中的 JAR 和目录条目在 JVM 系统类路径中将不再可用。如果应用程序使用上述方法之一,Sun 强烈建议使用无需假定资源包含在系统类路径中的等效方法。不依赖于 JVM 系统类路径的等效方法可在 java.lang.ClassLoader 中获得,并应尽量使用这些方法;例如:
java.net.URL url = ClassLoader.getSystemResource ("com/acme/tools/tools.properties");
java.net.URL url = this.getClass().getClassLoader().getResource ("com/acme/tools/tools.properties");
如果不能更改此代码,可以选择使用下一个发行版中将添加的一个新配置选项,以便设置 JVM 系统类路径。