File name encoding in jar

2019-07-09 09:50发布

问题:

My maven run creates different files in the target directory and compresses them into the jar file.

In case special characters like an Ü exist in the file names, the file names in the jar archive are not correctly encoded and showed as ├£. (The file contents are not affected)

As the files are correctly shown in the target directory, the issue must be caused by maven's jar:jar.

The interesting thing is that if I use the unzip command in Linux, the files are extracted with correct name, if I use Windows Explorer or 7zip in Windows, the names are not correct.

回答1:

I had the exact same problem and upgrading my maven-war-plugin version solved the problem I think you should do the same with your maven jar plugin

        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
                <attachClasses>true</attachClasses>
                <classesClassifier>classes</classesClassifier>
            </configuration>
        </plugin>
    </plugins>