问题
I created a jar using the Export functionality in Eclipse and when I try to execute it in the following way it fails
java -jar Code.jar
However it works correctly for
java -Dfile.encoding=UTF-8 -jar Code.jar
Current manifest file
Manifest-Version: 1.0
Main-Class: test.Reader
Class-Path: .
How can I mention the encoding inside the manifest file? So that I dont have to mention it explicitly while running the jar file?
回答1:
This indicates a problem with your code. Your code is currently depending on the default platform encoding, and doesn't work if that encoding is not "UTF-8". therefore, you should change the places in your code which depend on the default platform encoding to use the "UTF-8" encoding explicitly.
and, no, you can't specify that in the manifest.
来源:https://stackoverflow.com/questions/14867281/specify-encoding-in-manifest-file