在终端中运行 jar 文件时不呈现 Unicode 字符 (Eclipse / MacOS)
我在 Eclipse 中有一个 Java 项目,其中包含 ASCII 字符(◊、‡ 等)。当我将项目导出为可执行 jar 并在终端中运行该 jar (java -jar fileName.jar) 时,ascii 字符将呈现为“?”。它在 Eclipse 控制台中显示良好,但在终端中无法识别它们。
我最初将其作为代码中的字符(◊、·、—),然后将其更改为 unicode,希望能够修复它(\u25CA \u00B7 \u2014),但没有成功。这是相同的场景,显示在 Eclipse 中,但不在终端中。有没有办法导出来让这些字符显示出来?
我希望这已经很清楚了。任何帮助将不胜感激。
I have a Java project in Eclipse with ascii characters in it (◊ , ‡ , etc). When I export the project as an executable jar, and run that jar in the terminal (java -jar fileName.jar), the ascii characters are rendered as a '?'. It displays fine in the Eclipse console, but they aren't recognized in the terminal.
I originally had it as just the character ( ◊ , · , — ) in the code, then changed it to unicode in hope of that fixing it (\u25CA \u00B7 \u2014) with no luck. It was the same scenario, displayed in Eclipse, but not in the terminal. Is there a way to export it to allow these characters to be displayed?
I hope this was decently clear. Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要设置 -Dfile.encoding=utf-8,并确保您的终端是 UTF-8。
You will need to set -Dfile.encoding=utf-8, and also make sure that your terminal is UTF-8.