HOWTO: export LANG=en_US.ISO-8859-1 to Compile Java (javac) on Linux

| No TrackBacks
java_logo.gifI use Linux as much as possible for everything I do.  However, I often develop pieces of code on Windows, eventually compiling and deploying the entire project on Linux.  During my Ant builds, I've hit all kinds of interesting problems moving Java between Linux and Windows.  One of my least favorite javac errors is the "unmappable character for encoding UTF8" which looks like this:

[javac] /home/.../htmlGenerator/EscapeText.java:113: unmappable character for encoding UTF8
[javac]                     case '?': sb.append("®");break;
[javac]                           ^

A quick solution to the compilation error is to set the LANG environment variable to en_US.ISO-8859-1 using export:

(mark@skull)~/build> export LANG=en_US.ISO-8859-1
(mark@skull)~/build> echo $LANG
en_US.ISO-8859-1

It took me an hour or so to figure this one out.  Hopefully this post saves someone else the trouble.  Continue reading for a (somewhat) technical explanation.
The Windows system I was using had en_US.ISO-8859-1 configured as the default encoding.  Therefore, special characters didn't map from en_US.ISO-8859-1 to en_US.UTF-8 as expected at compile time.  The default character encoding scheme of the Linux box I'm using is en_US.UTF-8 as defined in /etc/sysconfig/i18n ...

(mark@skull)~/build> cat /etc/sysconfig/i18n
LANG="en_US.UTF-8"
SYSFONT="latarcyrheb-sun16"

Did You Find this Helpful?

Did you find this post helpful, or at least, interesting?

  

Send Mark a Direct Message

If you'd like to send me a direct message, please do so below. However, I do not publicly post comments or messages submitted directly to me. So, if you're going to try to SPAM me, or my blog, you're pretty much wasting your time.

400 characters remaining

Error

About Mark

A Silicon Valley native, Mark Kolich is a full-time Software Engineer, a casual entrepreneur, and a consultant for hire. A web technologies expert, his current focus is on building powerful and robust cloud-driven web-applications using Java, PHP, Perl, AJAX, DHTML, CSS, and JavaScript. His favorite programming languages are PHP, Java and JavaScript. He uses Linux, enjoys biking to work, loves building great software, and always writes elegant, readable, and maintainable code.

No TrackBacks

No trackbacks attached to this entry.

Twitter (@markkolich)

Translate

About this Entry

This page contains a single entry by Mark Kolich published on October 27, 2008 2:27 PM.

You Say Linksys I Say Tomato was the previous entry in this blog.

HOWTO: Configure VI To Stop Saving Annoying ~ (Tilde) Backup Files is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.