[ACCEPTED]-The encoding 'UTF-8' is not supported by the Java runtime-unicode

Accepted answer
Score: 12

According the documentation "Every implementation of 7 the Java platform is required to support 6 the following standard charsets... US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE, UTF-16." So 5 I doubt that Sun have released a build without 4 UTF-8 support.

The actual error message appears 3 to be from here, which is part of the Xerces 2 XML parser. I imagine it is the XML parser 1 where the problem is occurring.

Score: 7

Try the following program:

import java.nio.charset.Charset;

public class TestCharset {
    public static void main(String[] args) {

If this throws 7 an exception, then there is something wrong 6 with your JDK. If it prints "UTF-8" then 5 your JDK is OK, and your application is 4 doing something odd.

If that's the case, run 3 your app under the debugger, and put a breakpoint 2 in http://www.java2s.com/Open-Source/Java-Document/XML/xalan/org/apache/xml/serializer/ToStream.java.htm --that's the place this warning is produced, and 1 step to see why Xalan can't find the encoding.

Score: 2

Most probably someone put a catch() expecting 6 to have only unsupported encoding exceptions, so 5 he used the appropriate message. But he 4 has used too wide exception specification 3 (e.g. catch( Exception ex ) ), so when at 2 runtime he's got something else (non-valid 1 XML, NPE, ... ) the message became misleading.

Score: 0

Try a different (stable release) JVM. I 4 had this problem once and it turned out 3 that the machine was running a beta version 2 JVM that indeed did not support UTF-8, contrary 1 to the requirement in the API docs.

Score: 0

It should be "UTF8", without the dash.


Score: 0

If you are getting this message when using 1 a Transformer, try to specify the TransformerFactory:


Score: 0

This issue has been reported in Apache Jira 2 and jboss developer, it appears to be a 1 known issue



More Related questions