The moose likes Java in General and the fly likes specifying character set when compiling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "specifying character set when compiling" Watch "specifying character set when compiling" New topic

specifying character set when compiling

Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255
If I have a source file with String literals which are in Japanese, I want to make sure the String literals are read correctly by the compiler. How do I do that?
Jeff Verdegan

Joined: Jan 03, 2004
Posts: 6109

The javac command takes an optional -encoding argument.
Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255
I saved my .java file (called JsBuild.java) in UTF8, then typed
javac -encoding UTF8 JsBuild.java

but then I got an error message in Japanese, which, translated to English, is something like this:

JsBuild.java:1: \65279 is an improper character.
?import java.io.BufferedWriter;

The first line of the file is an import statement, with no character in front of the word "import".
I assume that the question mark is there because the character \65279 cannot be displayed correctly.
But I have no idea how that character got there, or how to get rid of it.
I agree. Here's the link: http://aspose.com/file-tools
subject: specifying character set when compiling
Similar Threads
does garbage collector runs in a loop?
Garbage from MindQ
String Literals and Garbage Collection.
annoying JSP error
Garbage Collection on object with null reference.