-2

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?

Lidia
  • 415
  • 1
  • 4
  • 21
  • Provide more detail about your question. But this looks like jdk issues, most likely you are running a non oracle jdk. com.sun.** should be from from oracle jdk – prodigy4440 Jan 02 '22 at 21:35
  • 1
    You would be doing the project a favor if you removed that import entirely. [Here is the correct way](https://docs.oracle.com/javase/8/docs/technotes/guides/io/fsp/zipfilesystemprovider.html) to create a FileSystem from a zip file. – VGR Jan 03 '22 at 13:44

1 Answers1

1

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.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216