Making Java work with Japanese text

If Japanese is set as your computer system's default language, JGloss should work without any further setup. If not, you should at least have a Japanese font installed. A Japanese input method, while not required, should also be installed. If you are using Sun's Java Runtime Environment for Windows, make sure that you have the international version installed (the smaller download only has English locale settings).

On Windows and MacOS X systems no font configuration should be neccessary. The first time JGloss is run, it tries to determine which font to use for displaying Japanese characters. If the Java default fonts don't contain Japanese characters, it tests if one of the fonts Arial Unicode MS , MS UI Gothic , MS Mincho , MS Gothic or Osaka is available and configures itself to use it. If none of the fonts work, no configuration is done and the default settings are kept. In this case Japanese characters will not display correctly. Read the section called “Style” for information on how to select fonts manually, or read on for information on how to change the Java default fonts.

Ths following paragraphs describe how to change the Java default font settings to use Japanese fonts. The descriptions apply to Sun's Java Runtime, other implementations may differ. Following these instructions should not be neccessary on Windows and MacOS X Systems since a custom font can be used, but have to be used on X11 Systems (blame the X font handling for that).

The easiest way to get Java to use Japanese fonts is to set the user.language parameter to ja : start JGloss as java -Duser.language=ja -jar jgloss.jar . This will make Java read the font definition from the font.properties.ja file of the JVM installation, and only works if the fonts used in the file are available. Unfortunately, at least on my Linux box, this will not make Java use the Japanese input method. On Unix systems, a second way is to set the LANG environment variable to ja_JP in a shell and then run JGloss from that shell. This will also make Java recognize an installed Japanese input method.

An alternative method, and one that allows more customization of what fonts to use, is to edit the font.properties files. The font.properties files are stored in the lib folder in the install directory of the Java Runtime Environment . They contain the definition of the default fonts used in Java dialogs and input elements. Which of the font.properties is used depends on the locale setting of the operating system, e. g. if you are running in a Japanese environment, the file font.properties.ja will be used. If there is no matching file for the current locale, the font.properties file is used. This is the case for most western locales. The file contains no definition for Japanese fonts, but you can edit it and add these fonts. The easiest way to do this is to simply rename the file font.properties.ja to font.properties (but make a backup of the original file first). You can also edit the file to make it use different fonts.

On Windows 2000 and XP , the JRE supports the Japanese input method regardless of the system language settings, but you will have to use one of the methods mentioned above to get Java to use Japanese fonts. I had no luck so far in getting the JRE to use the input method under Windows 98 .

Copying Japanese text between JGloss and other applications on X11 systems only works if JGloss is running in a Japanese environment. To achieve this, open a shell, set the environment variable LANG to ja_JP and start JGloss from that shell. Under MacOSX, copying Japanese text is problematic as well. To get copy and paste working properly, move nihongo to the first position in the Language tab of the System preference->International panel.

Java and X11 fonts

The font.properties.ja file of the Linux version of Java is configured for fonts contained in the Japanese distribution of Red Hat 6.1 (and the international Red Hat 7.x with Japanese support installed). It seems that these fonts (wadalab-gothic.ttf and watanabe-mincho.ttf) are not contained in most other Linux distributions. To make matters worse, Java only seems to accept TrueType fonts and not the Japanese bitmap fonts commonly installed with X11. This means that you will either have to install the mentioned TrueType fonts or edit the properties file to use a different already installed Japanese TrueType font.