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?
import com.sun.nio.zipfs.ZipFileSystem;
Could you please help me?
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?
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.
In Java 6 and earlier, the class does not exists
In Java 7 and Java 8, the class is in the "demo" suite.
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. However the class is not exposed by the module, and it is declared as package private. You are supposed to access it using the FileSystems.getFileSystem
method.
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). Then you remove the ZipFileSystem
import and replace it with an import for java.nio.FileSystem
. Finally change your code get a FileSystem
object by calling FileSystems.getFileSystem
with a URI with the scheme jar:
.
There is more information about the Zip Filesystem Provider in the Java SE documentation; e.g.