7

我在 2 台计算机上使用 netbeans 6.1。

在其中一个程序上:

public static void main(String argv[]) 
{
        System.out.println("שלום");
}

正常打印,而在其他问号上。
两种环境之间有什么区别?

编辑:在两台计算机上控制面板\区域和语言选项\高级设置为希伯来语
编辑:谢谢迈克尔伯尔,但编码的值已经是UTF-8。也许这与JVM有关?
编辑:我已经安装了 Eclipse,问题也出现在那里。我还尝试从具有相同结果的文件中读取希伯来语。
编辑: System.getProperty("file.encoding"); 返回“Cp1252”我试过 System.setProperty("file.encoding","UTF-8") 但问号仍然存在。

谢谢,
伊多

4

8 回答 8

3

确保使用支持希伯来字符的编码设置 NetBeans。来自NetBeans Wiki

要更改项目的语言编码:

  1. 在“项目”窗口中右键单击项目节点并选择“属性”。
  2. 在源下,从编码下拉字段中选择一个编码值。
于 2009-03-19T13:56:58.313 回答
2

You can't set the "file.encoding" property with System.setProperty(); it has to be set on the command line when the JVM is started with -Dfile.encoding=UTF-8. The value of this property is read during JVM initialization and cached. By the time your main method is invoked, the value has been cached and changes to the property are ignored.

于 2009-03-19T16:54:48.203 回答
1

你到底是如何运行程序的?它在哪里打印输出?它可以像 netbeans 或使用不同字体的控制台一样简单,其中一种不包括希伯来语字符。

要消除编译期间的编码问题,请尝试用其unicode 转义序列替换希伯来字符,看看结果是否不同。

于 2009-03-19T16:03:55.300 回答
1

I think I misunderstood your problem (I thought that the characters were not being displayed in the NetBeans editor properly). The exact steps to solve your problem might depend on the version of the OS you're running on. Win2K, WInXP, and Vista all have slightly different dialogs and wording unfortuantely.

Take a look at this help page for the JVM:

It sounds like you've already configured the system like it should be, but the devil is in the details - there are several different 'locale' settings on a system that might affect this (and for all I know the JVM might throw in one or two on its own).

于 2009-03-19T17:00:12.653 回答
1

希伯来语是默认安装的吗?可能是没有安装语言包?

控制面板 > 区域和语言选项 > 语言。选择“为复杂的脚本和从右到左的语言(包括泰语)安装文件”选项。这将安装对希伯来语的支持。您可能需要一张操作系统光盘。

于 2009-03-19T13:24:25.927 回答
0

通常它是默认编码:

控制面板\区域和语言选项\高级
(在组合上选择希伯来语)

更改此设置后,您必须重新启动。

于 2009-03-19T13:21:56.307 回答
0

对我有帮助的是(在Win7上): 在此处输入图像描述

于 2013-12-25T07:09:01.887 回答
0

上面没有一个答案是行不通的。

我花了大约一个小时,但发现问题不在字符串编码中,而是在默认编码中,IDE 从启动时就使用该编码。

因此,要在 Netbeans 控制台输出中获取希伯来语、阿拉伯语、俄语等符号,您需要修改netbeans.conf

搜索键netbeans_default_options并将-J-Dfile.encoding=UTF-8添加到引号中。

于 2017-02-22T14:07:19.603 回答