Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.nio.file.ProviderNotFoundException with jlink created runtime

Tags:

zip

nio

jlink

I am working on adopting jlink in order to create a much smaller runtime to embed with the macOS application version of a free software package, and I nearly have it working (with my application shrinking from around 260MB to 90MB). The problem that I am running into is that my software uses the ZIP filesystem, and when it tries to open such a filesystem when running with the jlink-created runtime, code that works fine with the normal OpenJDK 11 runtime suddenly crashes with:

java.nio.file.FileSystems.newFileSystem                  
java.nio.file.ProviderNotFoundException: Provider not found

I am assuming this is because jlink has no way of knowing without being told that ZIP filesystem support should be included in my runtime, since my code doesn’t explicitly mention any of its classes (they are used indirectly via java.nio).

So does anyone know how I can explicitly tell jlink to include them?

like image 798
James Elliott Avatar asked Oct 22 '25 10:10

James Elliott


1 Answers

Of course, shortly after posting this question, my google-fu improved, and I found the answer. In JDK 11, jdk.zipfs is its own module, containing this provider. So I just needed to add that to my --add-modules list, and it is now working.

like image 120
James Elliott Avatar answered Oct 26 '25 14:10

James Elliott