MacOS – Using `jar` to create “zip” file … Mac won’t open the zip, says “It is an unsupported format” … why

macoswindowszip

I have a build system with a command line driven batch file that uses jar (from Java JDK) on a Windows machine to make a zip file like this …

jar cf c:\target\Application-1.5.zip -C Application-1.5/ .

It "zips" up everything in the Application-1.5 directory into zip file Application-1.5.zip.

I used jar because there's no zip command at the command line on Windows.

When I download the zip file on a Windows 10 machine, Windows extracts the zip fine.

However, when I download the zip file on my MacBook (Catalina), and double-click on the zip file, the Mac won't unzip the file … it says … "Unable to expand "Application-1.5.zip". It is an unsupported format.

Also … when I use the jar command on the Mac to unzip it like this jar -xf ./Application-1.5.zip it works, so the file is "valid" but Mac's built-in unzipper doesn't like it.

What do I do to make a zip file that Mac will like?

Best Answer

I worked around my problem by installing 7-zip on Windows 10 and using that instead of jar like so ...

7z a c:\target\Application-1.5.zip .\Application-1.5\* -r 

Mac likes the zip file produced by 7-zip, so this will work for me.

But I'd still like to know how to make a zip file with jar that Mac's default unarchive can unzip.