导出可运行的JAR文件不支持UTF-8编码 - Java Eclipse [英] Exporting runnable JAR file does not support UTF-8 encoding - Java Eclipse

查看:376
本文介绍了导出可运行的JAR文件不支持UTF-8编码 - Java Eclipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用eclipse IDE制作了这个小型Java程序。我已经将工作空间设置为支持UTF-8,并且程序在从eclipse执行时运行愉快。

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.

程序的一部分是它将一些数据写入文件(需要UTF-8,因为它的阿拉伯语。)

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

我需要导出一个可运行的JAR文件给我的客户端这个程序......

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

我的问题:

当我使用导出到Runnable JAR文件导出程序时,它会直接运行,但数据是用阿拉伯语编写的,到文件最终是问号>。< ..如果我直接从eclipse编译并运行,就不会发生这个问题!

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!

如何解决这个问题?

你能否建议另一种方式来分发我的程序?

Could you suggest another way to distribute my program??

谢谢!

推荐答案

您没有提到用于写入文件的类,但是您是否尝试过显式设置编码?

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

例如:

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

这篇关于导出可运行的JAR文件不支持UTF-8编码 - Java Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆