tags:

views:

1549

answers:

4

Hi,

I wrote a small java application which output includes Unicode characters. When I use Eclipse to run it - I see all the output as expected.

The people who are supposed to use the application will run it as a jar file. I thought they could use standard cmd window, but in this window the Unicode appear as Gibberish.

Is there a way to make "cmd window" recognize the Unicode chars and display them properly? Or, is there any tool to easily run the jar file and get the correct output?

BTW - redirecting the output to a file works ok, but the program is interactive, so this will not be a good solution.

Thanks, Dikla

Edit: Thanks everybody for the suggestions. It seems that the cmd fonts don't have the specific characters I need, and this is why changing the code page did not solve my problem.

I found a way to add more monospaced fonts to the console, but after I add them any change that I want to do regarding the fonts (even choosing one of the original fonts in a different size) - is ignored.

I think that I will simply try with another tool, which supports chhosing a differnt font more easily.

Thanks!

A: 

try CMD /c /U java your.jar

Shay Erlichmen
He said already that redirection is not the problem.
Joey
This did not solve the problem... As far as I understand, /U influence only output of internal commands.
Dikla
Also, would be cmd /U /c, otherwise "/U is not recognized as an internal or external command".
maxwellb
+1  A: 

The problem is the font with which the windows console is displaying output. Unfortunately for you, this is a user setting.

I recommend you suggest that your users set their windows console font to Lucida Console. That font should be able to handle wide/unicode characters.

Randolpho
Even in Windows 7 the console windows default to raster fonts :-(. Very unfortunate.
Joey
I changed the font to Lucida. This did not solve the problem :(
Dikla
Thanks for the feedback Dikla. I clicked -1 since this in fact, does not help.
maxwellb
offtopic, but i think i prefer the look of raster :)
Charlie Somerville
@"...prefer the look of raster": seriously, the first image result of searching "raster" at Google: [http://tbn0.google.com/images?q=tbn:xWfQCT3QoeKIXM]
maxwellb
A: 

For any answers, check it first. This is a simple console program, which verifies that changing the font actually does not work.

using System;

namespace ConsoleApplication1
{
    class Program
    {
     static void Main( string[] args )
     {
      Console.OutputEncoding = System.Text.Encoding.UTF8;
      Console.WriteLine( "日本語です" );
      Console.Write( "Finished. Press a key. " );
      Console.ReadLine();
      return;
     }
    }
}

I will check to see if the answer is concretely "Cannot be done". Other avenues to check: use a different shell. i.e. Powershell? I'll see if that works.

However, you could do:

ConsoleApplication1.exe > output.txt
notepad.exe output.txt

Disclaimer: My example is C#, but the console application should still work as such.

And view the results like that, in the meanwhile.

maxwellb
Right, noticed the redirection. Interactivity. Hmm..
maxwellb
+2  A: 

Reference: Java Unicode on Windows Command Line

Try chcp 1252 or chcp 65001 from the command line. With Lucida Console or other font support.

maxwellb