next up previous contents index
Next: Mule Installation Up: Appendix Previous: Appendix

Subsections

Java

JDK 1.1 and above can be used to display Japanese under Linux. Get it from http://www.blackdown.org/java-linux.html You will need to adjust the font.properties file. If you install the jdk in /usr/local/jdk1.1.1, the font.properties file is in /usr/local/jdk1.1.1/lib/font.properties. Todd Rudick's file is shown below.

Font Properties

From Todd Rudick's JavaDict page.

# @(#)font.properties   1.8 97/03/03
#
#  Copyright (c) 1994-1996 by Sun Microsystems Inc
#
# Used to be: AWT Font default Properties for Japanese Solaris 
# Now it's: Modified to work on Linux (with the standard X Japanese fonts)
#

# Serif font definition
#
serif.plain.0=-linotype-times-medium-r-normal--*-%d-*-*-p-*-iso8859-1
serif.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0
serif.2=-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
serif.3=-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific
serif.4=--symbol-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific

serif.italic.0=-linotype-times-medium-i-normal--*-%d-*-*-p-*-iso8859-1

serif.bold.0=-linotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-1

serif.bolditalic.0=-linotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-1

# SansSerif font definition
#
sansserif.plain.0=-linotype-helvetica-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.plain.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0
sansserif.2=-morisawa-gothic medium bbb-medium-r-normal-sans-*-%d-*-*-m-*-jisx0201.1976-0
sansserif.3=-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific
sanserif.4=--symbol-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific

sansserif.italic.0=-linotype-helvetica-medium-o-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.italic.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0

sansserif.bold.0=-linotype-helvetica-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.bold.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0

sansserif.bolditalic.0=-linotype-helvetica-bold-o-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.bolditalic.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0

# Monospaced font definition
#
monospaced.plain.0=--courier-medium-r-normal--*-%d-*-*-m-*-iso8859-1
monospaced.plain.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0
monospaced.2=-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
monospaced.3=-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific
monospaced.4=--symbol-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific

monospaced.italic.0=--courier-medium-o-normal--*-%d-*-*-m-*-iso8859-1
monospaced.italic.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0

monospaced.bold.0=--courier-bold-r-normal--*-%d-*-*-m-*-iso8859-1
monospaced.bold.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0

monospaced.bolditalic.0=--courier-bold-o-normal--*-%d-*-*-m-*-iso8859-1
monospaced.bolditalic.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0

# Dialog font definition
#
dialog.plain.0=-b&h-lucida sans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1
dialog.plain.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0
dialog.2=-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
dialog.3=-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific
dialog.4=--symbol-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific

dialog.italic.0=-b&h-lucida sans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1
dialog.italic.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0

dialog.bold.0=-b&h-lucida sans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1
dialog.bold.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0

dialog.bolditalic.0=-b&h-lucida sans-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1
dialog.bolditalic.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0

# DialogInput font definition
#
dialoginput.plain.0=-b&h-lucida sans typewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.plain.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0
dialoginput.2=-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
dialoginput.3=-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific
dialoginput.4=--symbol-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific

dialoginput.italic.0=-b&h-lucida sans typewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.italic.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0

dialoginput.bold.0=-b&h-lucida sans typewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.bold.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0

dialoginput.bolditalic.0=-b&h-lucida sans typewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.bolditalic.1=-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0


# Default font definition
#
default.char=274f

# name aliases
#
# alias.timesroman=serif
# alias.helvetica=sansserif
# alias.courier=monospaced

# for backward compatibility
timesroman.plain.0=-linotype-times-medium-r-normal--*-%d-*-*-p-*-iso8859-1
timesroman.italic.0=-linotype-times-medium-i-normal--*-%d-*-*-p-*-iso8859-1
timesroman.bold.0=-linotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-1
timesroman.bolditalic.0=-linotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-1
#
helvetica.plain.0=-linotype-helvetica-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1
helvetica.italic.0=-linotype-helvetica-medium-o-normal-sans-*-%d-*-*-p-*-iso8859-1
helvetica.bold.0=-linotype-helvetica-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1
helvetica.bolditalic.0=-linotype-helvetica-bold-o-normal-sans-*-%d-*-*-p-*-iso8859-1
#
courier.plain.0=--courier-medium-r-normal--*-%d-*-*-m-*-iso8859-1
courier.italic.0=--courier-medium-o-normal--*-%d-*-*-m-*-iso8859-1
courier.bold.0=--courier-bold-r-normal--*-%d-*-*-m-*-iso8859-1
courier.bolditalic.0=--courier-bold-o-normal--*-%d-*-*-m-*-iso8859-1
#
zapfdingbats.0=-urw-itc zapfdingbats-medium-r-normal--*-%d-*-*-p-*-sun-fontspecific

# Static FontCharset info.
#
# This information is used by the font which is not indexed by Unicode.
# Such fonts can use their own subclass of FontCharset.
#
# This information can be overriden by describing more specific style.
# For example
#
#  fontcharset.serif.plain.3=SpecialSymbols
#  means serif.plain.3 font's index can be retrieved with the convert() method
#  of instance of SpecialSymbols and what kind of characters serif.plain.3 font
#  has can be judged with the isCovered() method of instance of SpecialSymbols.
#
fontcharset.serif.0=sun.io.CharToByte8859_1 
fontcharset.serif.1=sun.awt.motif.CharToByteX11JIS0208
fontcharset.serif.2=sun.awt.motif.CharToByteX11JIS0201
fontcharset.serif.3=sun.awt.motif.CharToByteX11Dingbats
fontcharset.serif.4=sun.awt.CharToByteSymbol

fontcharset.sansserif.0=sun.io.CharToByte8859_1
fontcharset.sansserif.1=sun.awt.motif.CharToByteX11JIS0208
fontcharset.sansserif.2=sun.awt.motif.CharToByteX11JIS0201
fontcharset.sansserif.3=sun.awt.motif.CharToByteX11Dingbats
fontcharset.sansserif.4=sun.awt.CharToByteSymbol

fontcharset.monospaced.0=sun.io.CharToByte8859_1
fontcharset.monospaced.1=sun.awt.motif.CharToByteX11JIS0208
fontcharset.monospaced.2=sun.awt.motif.CharToByteX11JIS0201
fontcharset.monospaced.3=sun.awt.motif.CharToByteX11Dingbats
fontcharset.monospaced.4=sun.awt.CharToByteSymbol

fontcharset.dialog.0=sun.io.CharToByte8859_1
fontcharset.dialog.1=sun.awt.motif.CharToByteX11JIS0208
fontcharset.dialog.2=sun.awt.motif.CharToByteX11JIS0201
fontcharset.dialog.3=sun.awt.motif.CharToByteX11Dingbats
fontcharset.dialog.4=sun.awt.CharToByteSymbol

fontcharset.dialoginput.0=sun.io.CharToByte8859_1
fontcharset.dialoginput.1=sun.awt.motif.CharToByteX11JIS0208
fontcharset.dialoginput.2=sun.awt.motif.CharToByteX11JIS0201
fontcharset.dialoginput.3=sun.awt.motif.CharToByteX11Dingbats
fontcharset.dialoginput.4=sun.awt.CharToByteSymbol

# exclusion info.
#
# This information describe exclusion ranges for each fonts.
#
# 'exclusion.serif.plain.0' overrides 'exclusion.serif.0', and
# 'exclusion.serif.0' overrides exclusion.0, and so on.
#

# XFontSet string
# X11 only properties
#

fontset.serif.plain=\
-linotype-times-medium-r-normal--*-%d-*-*-p-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0

fontset.serif.italic=\
-linotype-times-medium-i-normal--*-%d-*-*-p-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0

fontset.serif.bold=\
-linotype-times-bold-r-normal--*-%d-*-*-p-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0

fontset.serif.bolditalic=\
-linotype-times-bold-i-normal--*-%d-*-*-p-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0

fontset.sansserif.italic=\
-linotype-helvetica-medium-o-normal-sans-*-%d-*-*-p-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
 
fontset.sansserif.bold=\
-linotype-helvetica-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
 
fontset.sansserif.bolditalic=\
-linotype-helvetica-bold-o-normal-sans-*-%d-*-*-p-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
 
fontset.sansserif.plain=\
-linotype-helvetica-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0

fontset.monospaced.italic=\
-adobe-courier-medium-o-normal--*-%d-*-*-m-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
 
fontset.monospaced.bold=\
-adobe-courier-bold-r-normal--*-%d-*-*-m-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
 
fontset.monospaced.bolditalic=\
--courier-bold-o-normal--*-%d-*-*-m-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
 
fontset.monospaced.plain=\
--courier-medium-r-normal--*-%d-*-*-m-*-iso8859-1,
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0,
 
fontset.dialog.italic=\
-b&h-lucida sans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
 
fontset.dialog.bold=\
-b&h-lucida sans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
 
fontset.dialog.bolditalic=\
-b&h-lucida sans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
 
fontset.dialog.plain=\
-b&h-lucida sans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
 
fontset.dialoginput.italic=\
-b&h-lucida sans typewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
 
fontset.dialoginput.bold=\
-b&h-lucida sans typewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
 
fontset.dialoginput.bolditalic=\
-b&h-lucida sans typewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
 
fontset.dialoginput.plain=\
-b&h-lucida sans typewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1,\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0

#
fontset.default=\
-jis-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0208.1983-0,\
-sony-fixed-medium-r-normal--*-%d-*-*-*-*-jisx0201.1976-0
#

Java House

Java House is an excellent site for getting information about Java in Japanese. Naturally, some of the topics deal with Japanese text processing. The site is in Japanese.

http://java-house.center.nitech.ac.jp

How Java Handles Nihongo

The Java solution to the problem of multilingual computing is really elegant. Internally, Java handles everything in unicode. To get the bytes arrays converted into unicode, Java JDK 1.1 supplies the Linux programmer with getBytes("EUCJIS"), getBytes("JIS"), and getBytes("SJIS").

   
Examples of Java-Nihongo Code

As an example of some of the techniques used in Java JDK 1.1 and Servlet Development Kit 1.0, I'll include some test code below.

Since the JSDK did not have proper internationalization, I used getBytes("8859_1") as a trick to force it to take the input as an array of bytes. Hopefully, this trick will not be necessary in future releases. I now have a working servlet that mails me the contents of a Japanese HTML form and writes to a file in JIS, ShiftJIS, and EUC. The code is purely for testing. I'm posting it because I'm excited about the getBytes("EUC"), getBytes("SJIS"), and getBytes("JIS"), think it's mondo cool.

I got the getBytes("8859_1") trick from the Java House Japanese mailing list archives dealing Japanese and SQL databases that I may edit and put on my home page one day. Evidently, the database JDBC driver people had the same problem with Strings that I had with the servlet.

 ------------------------- begin test code  -------------

/* Test program that shows use of Strings and the new JDK 1.1 encoding
    conversion classes.  It also uses Sun's servlet development kit 1.0.
    I've tested input into the form with EUC encoding under Linux and
    ShiftJIS under Apple Macintosh Kanji Talk.  

This is the HTML test form.
    */

import java.io.*;
import java.util.*;
import java.net.*;

import javax.servlet.*;
import javax.servlet.http.*;


public
class test2 extends HttpServlet {

    public void doPost(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException
    {
        res.setContentType("text/html");

        // get name_ from HTTP apache server.  This is taken from
        // the HTML form
        String name_ = req.getParameter("name");

        // the String should be a unicode encoded string
        String uniString;
        // sends the output stream back to the HTTP server to send
        // to the browser
        ServletOutputStream out = res.getOutputStream();

        try {
          uniString = new String(name_.getBytes("8859_1"),"EUCJIS");
          byte[] eucByteArray = uniString.getBytes("EUCJIS");
          byte[] sjisByteArray = uniString.getBytes("SJIS");
          byte[] jisByteArray = uniString.getBytes("JIS");


          File eucOut = new File("/tmp/name_of_person.euc");
          File sjisOut = new File("/tmp/name_of_person.sjis");
          File jisOut = new File("/tmp/name_of_person.jis");

          FileOutputStream writesJis = new FileOutputStream(sjisOut);
          FileOutputStream writeEuc = new FileOutputStream(eucOut);
          FileOutputStream writeJIS = new FileOutputStream(jisOut);


          for (int j = 0; j < jisByteArray.length; j ++) {
                   writeJIS.write(jisByteArray[j]); 
          }
          writeJIS.flush();
          writeJIS.close();
          out.println("Wrote File");

        try { 
          // open a network socket on the SMTP port
          Socket server = new Socket("mail.twics.com", 25);     

          // set up network print stream
          PrintWriter sendmailout =
            new PrintWriter(
                            new BufferedWriter(
                                             new OutputStreamWriter(
                                                                    server.getOutputStream())), true);
          // send mail greetings and message
          sendmailout.println("HELO my_box.twics.com\n" 
                               + "MAIL FROM:\n"
                               + "RCPT TO:\n"
                               + "DATA\n");

          // send the body of the e-mail here

         sendmailout.println("Hi, this is an automated message"
                              + " with the results of the "
                              + "questionaire form." );
          
         Date date_written = new Date();
         sendmailout.println("This note was sent on " + date_written);

          for (int j = 0; j < jisByteArray.length; j ++) {
                   sendmailout.write(jisByteArray[j]); 
          }
          sendmailout.println("\n");

         // the mail program requires a single dot on a line
          // by itself
          sendmailout.println(".");
          sendmailout.println("QUIT");
          sendmailout.close();
        }  
        catch ( UnknownHostException e ) { 
          System.out.println("Can't find host."); 
        }  
        catch ( IOException e ) { 
          System.out.println("Error connecting to host."); 
        } 

          
          for (int j = 0; j < sjisByteArray.length; j ++) {
                   writesJis.write(sjisByteArray[j]); 
          }
          writesJis.flush();
          writesJis.close();
          out.println("Wrote File");

          for (int j = 0; j < eucByteArray.length; j ++) {
                  writeEuc.write(eucByteArray[j]); 
                  out.write(eucByteArray[j]);
          }
          writeEuc.flush();
          writeEuc.close();


        }
        catch (UnsupportedEncodingException encodErr) {
          System.out.println(encodErr);
          }

    }
}

next up previous contents index
Next: Mule Installation Up: Appendix Previous: Appendix
Craig Toshio Oda
1998-05-07