Back to main page

The Quick-N-Dirty Guide to Inputting Japanese in Linux and some BSDs

Please note that I haven't been maintaining this page. I would recommend that you doublecheck my more detailed page or the TLUG wiki and look for their Japanese howto section.

The aim of this QND guide is to get you up and running quickly and being able to input Japanese in Linux and some of the BSDs. There will be far more how than why here.

1.) Do you have the Necessary Tools?

You will need a few items for this to work. The first choice is scim, anthy and scim-anthy. FreeBSD, Gentoo, and Debian have these available. In many other distributions, you will have to download and install them and they may not work.

The second choice is canna, and kinput2. For NetBSD, you will also need a terminal capable of displaying Japanese. If you are unsure how to find these programs in your distribution, take a quick look at our software guide for information about getting and installing the items.

If you are running a distribution that doesn't work with scim and anthy and doesn't have a package for kinput2 and canna, you might find our vanilla kinput-canna tarball useful. Download it here take a quick look at our guide on installing from source then read on to step two, where we give a bit more information.

However, it is at least worth trying to get scim and anthy to work. Scim can be downloaded here, anthy here (choose anthy, not anthy-ss and choose the latest version) and scim-anthy here.

One might also need Japanese fonts. Some kochi fonts are available here. You want the package called kochi-substitute-20030809.tar.bz2

2.) Installing the Necessary Tools

If these packages were included with your distribution, then hopefully you've installed them. For scim, anthy and scim-anthy, all are installed in the same way. Say the version of anthy is anthy-6700.
tar -zxvf anthy-6700.tar.gz
cd anthy-6700
./configure --prefix=/usr && make && make install

Follow the same procedure for scim and scim-anthy, in the order given, that is, anthy first, then scim then scim-anthy. If you have to use our vanilla tarball, then do the following to install canna and kinput2.

tar -jxvf vanillajpn.tar.bz2
tar -zxvf Canna*
tar -zxvf kinput
cd Canna36p1
make Makefile
make canna
make install

Next, kinput2.
Do a cd back to the directory in which you untarred it and then

cd kinput2-v3.1-beta3
make Makefile
make depend
make install

In most cases, you will want cannaserver to start upon bootup. This varies with each distribution, so hopefully you know how to do it with yours. If not, check out our QND guide about running a program upon boot and see if your distribution is mentioned there.

On some distributions, the cannaserver installed from our vanilla package will, after being started, echo Terminated back to the console. However it is still running and the line can be ignored.

Next the kochi fonts. Untar it.

tar -jxvf kochi-substitute-20030809.tar.bz2

In the kochi-substitute-20030809 directory, you will see gothic and mincho fonts, they have a .ttf extension on the end of their names. Move them to /usr/X11R6/lib/X11/fonts/TrueType if you have it, otherwise, put them in /usr/X11R6/lib/X11/fonts/TTF.

3.) Configuring the Necessary Tools

I am assuming that you want your menus and such to be in English. If you boot up in graphic mode, these variables can probably be placed in your shell's .profile (eg .bash_profile) script and it should work. (It does in RH derivatives.) If you boot up in text mode, put them in your .xinitrc (in RH and its clones, .Xclients). If you are using scim and anthy
export XMODIFIERS='@im=SCIM'
export GT_IM_MODULE='scim'
export QT_IM_MODULE='scim'
export LC_CTYPE=ja_JP.utf8
scim -d

If using the kinput2 canna combination

export XMODIFIERS='@im=kinput2'
export LC_CTYPE=ja_JP.utf8
kinput2 -canna &

Note that these lines come before you call your window manager. The last line of your .xinitrc should be the exec fluxbox, startkde or whatever command you use to call your window manager.

The LC_CTYPE variable is case sensitive. The majority of Linux distributions use ja_JP.utf8 but some don't. To check this do

locale -a | grep ja_JP

If it comes out something like ja_JP.UTF-8 use that rather than utf8.

For FreeBSD 5.x and later it is ja_JP.UTF-8. In FreeBSD's case, you can simply cd into /usr/ports/japanese/scim-anthy and type make install clean. This will install both scim and anthy.

The default way to call scim-anthy is with ctl+space, kinput2-canna is called with shift+space.

4.) Test the Necessary Tools

Fire up X. In all but NetBSD, covered below, open up a uxterm. If using kinput2 hit shift+space and you should see a hiragana a. Type a word in romaji and hiragana should show up on the screen. If you hit space, it will select kanji.

With scim anthy, hit ctl+space and you should see a little widget in the lower right of your screen. It should do the same thing, show hiragana. When you hit the space bar, kanji should be selected.

If using scim and you only see dotted squares, this means that for some reason, scim can't find the appropriate fonts. (This happened to me once with Vector Linux, an offshoot of Slack, though not Slackware itself.) If you select what you want and hit enter, the correct Japanese will show up in the terminal, however, you are probably better off using the kinput2 canna combination.

Sometimes, the terminal itself will not properly display Japanese, but if you open up vim (and it seems that it has to be vim, not elvis or nvi) Japanese should display properly. Most other applications, such as OpenOffice, firefox and the various mail clients such as sylpheed, should also work.

5.) Distro specific issues.

At present, if you choose to install Japanese support upon installation of RedHat, Fedora and its clones, it still installs canna. However, at least in Fedora Core 4, scim, anthy and scim-anthy are available. So first stop canna and remove it, then install scim, anthy and scim-anthy.

pkill cannaserver
yum remove Canna
yum install scim-anthy 
This will pull in scim and anthy as dependencies.

As Fedora boots into X by default, you want to define the necessary variables in your .bash_profile. Add to your bash_profile

export XMODIFIERS='@im=SCIM'
export GTK_IM_MODULE='scim'
export QT_IM_MODULE='scim'
export LC_CTYPE=ja_JP.utf8
scim -d

ArchLinux's version of the packages work out of the box.

pacman -Sy scim-anthy

Then add the lines mentioned above to your .xinitrc and it Just Works(TM). You can also add fonts.

pacman -Sy ttf-arphic-uming ttf-arphic-ukai

Note that as of early March, 2006, there is a new glibc package that doesn't include locales. Desired locales should be created using locale-gen. If you go into /etc/locale.gen you'll see a list of locales all commented out. Uncomment the ones you want, for example, en_US.UTF8 UTF-8, ja_JP.UTF8 UTF-8 and then, at a command prompt type

You should see a message that the desired locales were created.

There is a rather detailed howto, that is kept current, on the Gentoo forums. It can be found here.

Kevin W. (AKA sandcrawler on Gentoo Forums) was kind enough to send me his mini Gentoo howto.

He added the following USE variables

immqt-bc nls cjk unicode


emerge --newuse world

Emerge the necessary programs

emerge scim anthy scim-anthy scim-qtimm

He added the following to his .bash_profile

export XMODIFIERS='@im=SCIM'
export GTK_IM_MODULE="scim"
export QT_IM_MODULE="scim"
export LC_CTYPE=jsa_JP.utf8
scim -f socket -c socket -d

(If not booting into X, you might leave off the scim line and put it in .xinitrc or whatever file you use to start X.)

This enables him to input Japanese in most applications.

If you didn't install the glibc-i18n libraries during installation, you will have to grab the installation cd and install them. (They're in the l directory. Note that is a lower case L, not the numeral "one").

Slackware's default vi editor is elvis. You will have to install vim to get Japanese to display properly in a vi type editor.

Although scim, anthy and scim-anthy compile in Vector, they don't display the input dialog properly, unless the gimp is installed. I'm not sure which packages the gimp includes that make it work, but in any case, when I installed it without choosing to install the gimp, I would get dotted squares instead of hiragana. According to the scim faq, this means that scim can't find the fonts, however, once I hit enter, hiragana would display in the term window. I never did solve this, and just put in the gimp. Afterwards, I could deinstall gimp with removepkg and it still worked.

Like Slack, Vector uses elvis as its default editor. If you need Japanese in a text editor, for instance, with mutt, you should install vim. It doesn't seem available in the Vector package repository, however, one can simply go to Slackware's package search site and find it there.

Debian and its derivatives (Mepis, Ubuntu, etc)
There is a brief but useful howto for Ubuntu that should work with almost all Debian based distrbutions. It can be found here on their forums.

If you're using Ubuntu and are using Breezy or later, it's become easier. Their wiki has a howto here.

Note that Debian's default vi editor is not vim. As mentioned above, sometimes, in xterms, things only work in vim, so you may want to install it with apt-get install vim

As of Ubuntu's Dapper flight 3 scim-anthy is available.

FreeBSD's default vi editor is nvi. Once again, I recommend, if you plan to use Japanese in xterms (as opposed to web browsers and the like) you install vim-lite.

NetBSD 2.x doesn't have the ja_JP.UTF-8 locale in the base distribution. The easiest workaround is to use euc. It also doesn't have the scim-anthy packages. Instead, it has anthy and uim. The packages are in /usr/pkgsrc/inputmethod.
cd /usr/pkgsrc/inputmethod/anthy
make install clean
cd ../uim
make PKG_OPTIONS.uim="-canna" install clean

If you wish to use UTF-8, I've had the best luck with rxvt-unicode in /usr/pkgsrc/x11. In your .xinitrc, before the line calling the window manager, if you were using rxvt, mrxvt or another euc but not UTF-8 capapble terminal
export LC_CTYPE=ja_JP.eucJP 
export XMODIFIERS=@im=uim
uim-xim --engine=anthy &

Once you have started X, hitting shift+space will enable you to input Japanese. To turn off Japanese input, hit shift+space again.

If you wish to use UTF-8, then you may have to generate a ja_JP.UTF-8 locale. Download en_US.UTF-8.src from

Then, assuming your user name is joe and you downloaded it into your home directory, as root or with root privilege
cd /usr/share/locale
mklocale < /home/joe/en_US.UTF-8.src > ja_JP.UTF-8

After that, you can use it with urxvt. Regardless of whether you use euc or UTF-8, it's invoked by hitting shift-space.

(It may or may not be necessary to generate the ja_JP.UTF-8 locale--I've had mixed results. In general, using en_US.UTF-8 as my LC_CTYPE, I'm able to input Japanese in urxvt.)

(The scim and scim-anthy packages are now available in NetBSD's Works In Progress collection.)

If you choose to use kinput2 and canna, it is best done in this order, with the options done as shown.

cd /usr/pkgsrc/inputmethod/canna
make install clean
cd ../kinput2
make PKG_OPTIONS.kinput2="-sj3 -wnn" install clean

if you use euc rather than utf8, the LC_CTYPE in your .xinitrc file should read

export LC_CTYPE=ja_JP.eucJP
Your .xinitrc, assuming you want kinput to always be running should have
kinput2 -canna &
export XFILESEARCHPATH=/usr/pkg/lib/X11/app-defaults/Kinput2

The uxterm doesn't work with euc, so you also have to install an xterm that can handle it. If you use rxvt after installation, you have to edit /usr/pkg/lib/X11/app-defaults/Rxvt. You will see several lines marked !Rxvt.multichar_encoding

Remove the ! from the line that has eucj at the end. Also, put a ! at the beginning of the top line, which ends with noenc.

My own opinion is that as of NetBSD 3.x in December 2005, the eucJP fonts are far easier on the eyes than the UTF-8 ones.

Actually, I prefer mrxvt to rxvt. If one chooses to use that, then you have to slightly edit the Makefile. You'll see a section of CONFIGURE_ARGS+=. Add the following to it
CONFIGURE_ARGS+=	--enable-xim
CONFIGURE_ARGS+=	--enable-cjk
CONFIGURE_ARGS+=	--with-encoding=eucjp

DragonFly uses NetBSD's pkgsrc, so the instructions are almost identical to those for NetBSD. Unlike NetBSD, it does have ja_JP.UTF-8 installed by default. Those familiar with DF will also know to type bmake rather than make when following the instructions above.

Congratulations, you're done. Hopefully, you can now input Japanese in your *nix system.

References My page on Japanese input.
I have a far more detailed page on this, with links to other people's pages as well.

Back to main page