Exporting runnable JAR file does not support UTF-8 encoding - Java Eclipse

a 夏天 提交于 2019-12-04 05:32:47

问题


I made this small Java program using eclipse IDE. I have set the workspace to support UTF-8 and the program runs happily when executed from eclipse.

Part of the program is that it writes some data to a file (needs UTF-8, since its in Arabic).

I need to export a runnable JAR file to give my client this program...

My Problem:

When I export the program using "Export to Runnable JAR file", it runs perectly, BUT the data, written in Arabic, to the file ends up being question marks >.< .. This problem does not happen if I compile and run directly from eclipse!

Any idea on how to solve this?

Could you suggest another way to distribute my program??

Thanks!


回答1:


You don't mention the classes you use to write to file, but have you tried setting the encoding explicitly?

For example:

Writer out = new OutputStreamWriter(fos, "UTF8");


来源:https://stackoverflow.com/questions/4934013/exporting-runnable-jar-file-does-not-support-utf-8-encoding-java-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!