2

I have some problem with javac. I cannot compile my java files which contain Japanese text in it. My office pc is Japanese and have no problem to compile and run java files but my home pc is in English and i can't even compile same java file.

All i have is "error: unmappable character for encoding Cp1252"

I have tried to save file as utf-8 and shift_jis and compile it javac -encoding "utf-8" SomeSoruceFile.java but no luck.

Any help will consider great appreciate.

  • see if one of this links is helping https://www.google.com/#q=javac+set+locale or http://stackoverflow.com/questions/6217297/forcing-the-use-of-english-in-jdk7-tools – user2485710 Aug 01 '13 at 16:23
  • what encoding is your source in? you are saying you have converted the files to utf8? – 75inchpianist Aug 01 '13 at 16:25
  • If using utf-8 encoding file with japanese text in it works fine with Japanese OS pc, however English OS pc fail to compile. So i have changed utf-8 to Shift_JIS and compile it with Shift_Jis in English OS. –  Aug 02 '13 at 02:13

2 Answers2

2

Okay guys I have solved problem.

I am going to write solution and hope it may help someone else and save his/her hours.

Compile java files which has Japanese text in it as follow.

javac -encoding "Shift_JIS" SomeSourceFile.java

2

You have to save the files as UTF-8 in your Japanese PC and then you can copy them to your English PC. Eclipse uses the system default encoding, so a good practice is to change it to UTF-8 before starting a new project in Windows/Mac

Pablo Lozano
  • 10,122
  • 2
  • 38
  • 59