How to see Japanese characters in java, under Solaris

This has also been confirmed to work under Linux, and SunOS.

I don't understand why sun decided to make this so difficult. They could have just provided the full scalable japanese fonts for free. But.. you don't need em anyway! There are two Japanese(Well, kanji), non-scalable fonts provided with EVERY VERSION OF SOLARIS 2.x, and indeed most modern Unixen.

Anyway, here's how to get java to use the kanji fonts.

Directions for java 1.2 and 1.2 are lower down.

Directions for java 1.1, and netscape

In $JAVA_HOME/lib, edit the file "font.properties". It should already exist. [If you're trying to get netscape java to work, edit /usr/local/netscape/java/classes/font.properties]

Then add entries for serif, sansserif, monospaced, but most importantly, dialog. You should be able to just add the following lines at the top:

   # Japanese font, presumably jis, here. This is a "lets grab something" game
   # The "3" should actually be changed to whatever does not conflict
   # with what is already present in the file
   dialog.plain.3=*jisx0208.1983-0
   # If you want to make sure the above is obnoxiously big, try one of:
   #dialog.plain.3=kanji24
   #dialog.plain.3=*--24-*-jisx0208.1983-0
   #
   # And here's the "magic" that makes the above actually work
   # make sure the stuff between "fontcharset" and "=" matches up.
   fontcharset.dialog.plain.3=CharToByteX11JIS0208

Note1: If this doesn't work, use "CharToByteJIS0208", instead of "CharToByteX11JIS0208"

Note2: It doesn't matter if the other lines say

fontcharset.xx.x=sun.awt.CharToByteXXXX
Just write it like I show above, skipping "sun.awt" and the like.

Repeat as needed, for serif, dialoginput, monospaced, etc. However, jdrill by default only needs the dialog font entries.


Directions for java 1.2 and beyond

The java 1.2.2 runtime, and later versions for UNIX, have a file called font.properties.UTF8.5.7, in the directory $JAVA_HOME/jre/lib

[This actually stands for "Solaris 5.7 version", but seems to be the best general version for all UNIXen.]

Copy "font.properties.UTF8.5.7" to "font.properties", in the same directory. I specify UTF8.5.8, vs UTF8, because the plain UTF8 file seems to have some uncomment font entries in it.

Or with jdk1.3 and solaris 8, copy "font.properties.ja", which seems to not have any missing font complaints. If you have ALL the optional fonts installed, you shouldn't get any complaints about "Cannot convert string". But if you are using XFree86, you may have to stick to font.properties.UTF8.5.7

Once you have copied the right font.properties file, you should be able to see Japanese chars (and possibly other interesting ones),providing you have the "optional fonts" installed. This should work without you having to do backflips with your locale. But see the note below. (If, on the other hand, you normally use your computer in a locale that matches one of the other font.properties.XXX extensions, you might want to copy the "UTF8.5.7" file to that file, instead)

Critical Point

Oddly enough, this does not seem to work with jdk1.3 if your "LC_ALL" variable is set to en_US.ISO8859-15, or is unset altogether. So do

export LC_ALL
LC_ALL=POSIX
and the above method should work for you.
If you have any suggestions, comments, or "hey, it works on platform xxx, cool", drop me a line! phil@bolthole.com

Bolthole.com