tags:

views:

753

answers:

7

Hi, I am using netbeans 6.1 on 2 computers.

on one of them the program:

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

prints normally, and the on the other question marks.
what can be the difference between the 2 environments?

edit: on both computers Control Panel \ Regional and Language Options \ Advanced is set to hebrew
edit: Thank you Michael Burr, but the value of the encoding is already UTF-8. Maybe this something with the JVM?
edit: I have installed Eclipse and the problem occurs there as well. I also tried reading the hebrew from a file with the same result.
edit: System.getProperty("file.encoding"); returns "Cp1252" I tried System.setProperty("file.encoding","UTF-8") but the question marks remains.

Thanks,
Ido

A: 

Usually it's the default encoding on:

Control Panel \ Regional and Language Options \ Advanced
(Select Hebrew on the combo)

You'll have to restart after changing this setting.

Kobi
+1  A: 

Is Hebrew installed by default? Could be that a language pack isn't installed?

Control Panel > Regional and Language Options > Languages. Select the 'Install files for complex script and right-to-left languages (including Thai)' option. This will install support for Hebrew. You'll probably need an OS disc.

Jeremy Cron
you mean Windows language pack?
idober
yes. I'm not sure about Hebrew, but we had to install a separate language pack for Japanese. we saw '?' in some places and 'boxes' in others.
Jeremy Cron
'?' means the encoding is set up wrong, boxes mean the font doesn't support the characters.
Michael Burr
+4  A: 

Make sure that NetBeans is set up with an encoding that supports Hebrew characters. From the NetBeans Wiki:

To change the language encoding for a project:

  1. Right-click a project node in the Projects windows and choose Properties.
  2. Under Sources, select an encoding value from the Encoding drop-down field.
Michael Burr
+1  A: 

How exactly are you running the program? Where does it print its output? It could be as simple as netbeans or the console using different fonts, one of which does not include Hebrew characters.

To eliminate encoding problems during compilation, try replacing the Hebrew characters with their unicode escape sequences and see if the result is different.

Michael Borgwardt
a very strange thing happened,after i changed the the added a VM option: "-Dfile.encoding=UTF-8" It worked. but after I restarted my computer i got ש�וֹט instead of Hebrew, even when i use Unicode escape sequences.
idober
That VM option shouldn't be able to have any effect after a restart, but maybe your also fiddled with the locale settings and that took effect only after a restart?
Michael Borgwardt
+2  A: 

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.

erickson
Cool, so how do I change the the JVM Netbeans uses?
idober
+1  A: 

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).

Michael Burr
+2  A: 

I have found what I was looking for: VM options

Thanks guys for the help

Although It is an ad-hoc solution, it serves my needs for now.

idober