在清单文件中指定编码 [英] Specify encoding in manifest file
问题描述
我使用Eclipse中的Export功能创建了一个jar,当我尝试以以下方式执行它时,它失败了
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
但是它对于
java -Dfile.encoding=UTF-8 -jar Code.jar
当前清单文件
Manifest-Version: 1.0
Main-Class: test.Reader
Class-Path: .
如何提及清单文件中的编码?这样我在运行jar文件时不必明确提及它?
How can I mention the encoding inside the manifest file? So that I dont have to mention it explicitly while running the jar file?
推荐答案
这表明您的代码有问题.您的代码当前取决于默认的平台编码,并且如果该编码不是"UTF-8",则该代码将无效.因此,您应该根据默认平台编码更改代码中的位置,以显式使用"UTF-8"编码.
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.
这篇关于在清单文件中指定编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!