-Dfile.encoding=UTF-8

General discussion on the JZOS batch launcher and toolkit
Post Reply
fady
Posts: 1
Joined: Tue Nov 15, 2005 9:01 am

-Dfile.encoding=UTF-8

Post by fady »

I am running Tomcat with Jzos fine.

When I try to replace the ISO8859-1 encoding with UTF-8 on startup of the JVM though, the output redirection fails but Tomcat continues to work fine.

As the Java application I am running does a lot of XML processing and since XML files are usually UTF-8 encoded (as opposed to ISO8859-1) I was wondering if you guys have considered supporting UTF-8 in the batch launcher.

Thanks
Guest

Post by Guest »

Can you post errors or symtoms that you see when it fails?
Guest

Post by Guest »

I get this:

java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2)
Classic VM (build 1.4.2, J2RE 1.4.2 IBM z/OS Persistent Reusable VM build cm142s
12:55:51 JZOSVM14(T): <- createJvm()
12:55:51 JZOSVM14(T): -> redirectStandardStreams()
12:55:51 JZOSVM14(T): No JZOS_OUTPUT_ENCODING found, using the default codeset '
12:55:51 JZOSVM14(T): -> invoke()
12:55:51 JZOSVM14(D): About to invoke com.dovetail.jzos.ZUtil.redirectStandardSt
Exception occurred invoking com.dovetail.jzos.ZUtil.redirectStandardStreams()

Exception in thread "main"
12:55:51 JZOSVM14(T): <- invoke()
12:55:51 JZOSVM14(T): <- redirectStandardStreams()

Thanks
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

Unfortunately, JZOS currently doesn't support default output encodings that are not 'single-byte'. UTF-8 is an encoding that will generate multi-byte encodings for some non-ascii characters.

The reason for this limitation, in case you are curious, is found in the JZOS output redirection framework class called "TranscodingPrintStream". This class is used to replace System.out and System.err, which are java.io.PrintStreams (unfortunate remnants from JAVA 1.1). Anyway, PrintStreams are subclasses of OutputStream that have both character (text) and byte (binary) output methods. TranscodingPrintStream builds a byte-to-byte trancoding table to handle the binary data, which limits its ability to handle multi-byte encodings.

Another problem is that the JDK's JNI interface doesn't seem to be conveying exception messages properly to the launcher. We need to probably address this with IBM. You should have seen the following exception:

UnsupportedEncodingException: Both the default encoding and the encoding IBM-1047 must be single byte encodings.

(This would have made it clear to you what was wrong)

Thank you for reporting this issue. We will look at seeing if there is a way to address it in the future.

You really should try to write your XML application so that it doesn't depend on the default file.encoding of the JVM. Of course, you may have inherited or are trying to reuse code that isn't codepage-careful. In this case, using ISO-8859-1 as your default encoding will usually work since it matches UTF-8 for common printable characters.
Post Reply