Solved

Have to print russian language data in JAVA

Posted on 2011-02-16
26
614 Views
Last Modified: 2012-06-21
I get the russian language data from the database adn I am able to view the proper data in my debugger. But when I try to use System.out.println to print the data to check, I am getting everything ???????????. I don't know how to solve this. I am using struts and I don't know what encoding/decoding have they done in the database.

Thanks,
0
Comment
Question by:DHAMIN
  • 8
  • 8
  • 7
  • +2
26 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 34906516
Your console probably doesn't support what you're attempting to do. Are you using Windows?
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 166 total points
ID: 34906541
The following will tell you what the runtime thinks your encoding is. It's not interested in the database encoding, although if you have mixed languages, UTF-8 is probably a good choice
System.out.println(System.getProperty("file.encoding"));

Open in new window

0
 

Author Comment

by:DHAMIN
ID: 34906570
Yes. I am using Windows.
0
 

Author Comment

by:DHAMIN
ID: 34906597
When I tried to check the encoding by using your above code, it returns me Cp1252
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34906632
Yes, that's all default. It's going to be a lot easier for you to view Russian output in an IDE console. Can you arrange it that way?
0
 

Author Comment

by:DHAMIN
ID: 34906647
Yes. I am trying to print the russian data to my console and I using IntellIJ. Thats when it is printing the ????.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34906715
You need to use an encoding that supports Russian. In this case, for your debugging purposes, try setting your IDE with

-Dfile.encoding=UTF-8
0
 

Author Comment

by:DHAMIN
ID: 34906733
It is already been set as UTF-8 only.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34906743
You will of course need Russian font support
0
 

Author Comment

by:DHAMIN
ID: 34906764
Yes. But how will I get that?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34906894
0
 

Author Comment

by:DHAMIN
ID: 34906915
But I am using windows 7.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 47

Expert Comment

by:for_yan
ID: 34907113
But did you do necessary setup in Control Panel?
Don't know exactly in Windows7 but in XP you go to Control Panel, Reginal and Language,
Languge - Details - Advanced - Add, and find Russian
Can you see Russian say in Windows Word?
I have IntelliJ and I can see and type Russian within it
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34907154
No, sorry, I was wrong - read the trail more attentively - I can type Russian in IntelliJIdea,
but System.out.println indeed prints ????
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34909676

In Idea go to Settings | File Encodings and change it to UTF-8.
You don't need to add -Dfile.encoding=UTF-8 to runtime JVM - IDEA adds this automatically

Try to change in Settings | File Encodings - it started working for me
when I did it.
0
 

Author Comment

by:DHAMIN
ID: 34910230
Already the encoding is in UTF-8. But it is still printing ?????.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34910255
You probably don't have Russian font support. Try changing the font
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34910269
Which version of Idea are you using? What Java version?
Fiirst try to create very simple brand new project and set File Encoding to UTF-8 - I also
had some problems but eventually this worked for me, so it probably should work for you.
I have XP rather than Winndows 7, but other than that it is the same.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34910275
No you have Russian font as you are typing in Russina in the editor window - correct?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 34910931
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34910970
This is rather Idea issue, not general Java -
I just had it System.out.println(russin text here)  - and when I changed this Setting | File Encoding
it started working for me - I'm sure it should work for you
I have version 9.0.1 of Idea, but I'm pretty sure it should be the same
on previouis versions.

can you see Russian in say Word for Windows on your computer?
But I think once you can see it in the editor window of Idea, it should also work in System.out.print
with this setting
0
 
LVL 47

Expert Comment

by:for_yan
ID: 34911733
I attach a very simple project created by Idea 9 - if you have 9 or 10 - it should work
for you. Just rename the RussianPrintout2.txt to RussianPrintout2.iml
and the folder "idea" to  ".idea" (dot should be the first character),
as EE do not allow to upload .iml files and foleders starting with dot

I guess if it works for me and prints in Russian, why shouldn't it work for you

RussianPrintout2.zip
0
 
LVL 92

Accepted Solution

by:
objects earned 168 total points
ID: 34911897
you should just need to change the encoding of your project to UTF8, no need to worry about the font

0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 166 total points
ID: 34911941
Yes, it is in File Encoding in settings of the project that needs to be changed to UTF-8; it should work.
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 37514370
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This video teaches viewers about errors in exception handling.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now