[英]How to solve java import com.sun.nio.zipfs.ZipFileSystem?
I'm solving dependencies for an open source java project and I can't find to what jar this import belongs, maybe it's a special JDK it belongs to?我正在解决开源 java 项目的依赖项,但我找不到这个导入属于什么 jar,也许它属于它的特殊 JDK?
import com.sun.nio.zipfs.ZipFileSystem;
Could you please help me?请你帮助我好吗?
Based on what I can see, com.sun.nio.zipfs.ZipFileSystem
class was not part of the official Java SE libraries.根据我所见,
com.sun.nio.zipfs.ZipFileSystem
class 不是官方 Java SE 库的一部分。
In Java 6 and earlier, the class does not exists在 Java 6 及更早版本中,不存在 class
In Java 7 and Java 8, the class is in the "demo" suite.在 Java 7 和 Java 8 中,class 位于“演示”套件中。
In Java 9 and later, the class is no longer present in the "demo" suite... but there is now a class called jdk.nio.zipfs.ZipFileSystem
in the jdk.zipfs
module.在 Java 9 及更高版本中,class 不再存在于“演示”套件中......但现在在
jdk.zipfs
模块中有一个名为jdk.nio.zipfs.ZipFileSystem
的 class。 However the class is not exposed by the module, and it is declared as package private.但是 class 没有被模块公开,它被声明为 package 私有。 You are supposed to access it using the
FileSystems.getFileSystem
method.您应该使用
FileSystems.getFileSystem
方法访问它。
So to port your code to Java 9+, you need to add that module to your Java 9+ module dependencies (if your code is modular).因此,要将您的代码移植到 Java 9+,您需要将该模块添加到您的 Java 9+ 模块依赖项(如果您的代码是模块化的)。 Then you remove the
ZipFileSystem
import and replace it with an import for java.nio.FileSystem
.然后删除
ZipFileSystem
导入并将其替换为java.nio.FileSystem
的导入。 Finally change your code get a FileSystem
object by calling FileSystems.getFileSystem
with a URI with the scheme jar:
.最后更改您的代码,通过使用带有方案
jar:
的 URI 调用FileSystems.getFileSystem
来获得FileSystem
object。
There is more information about the Zip Filesystem Provider in the Java SE documentation; Java SE 文档中有关于 Zip 文件系统提供程序的更多信息; eg
例如
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.