[jboss-user] [JBoss Portal] - Re: UnsupportedEncodingException when converting a String to

marcoscf do-not-reply at jboss.com
Wed Jan 23 10:30:51 EST 2008


I had the same problem.
JBoss 4.0.4.GA, JDK 1.5

The available charsets on your Java installation depend on the type of installation you performed (international or not). If you performed an "international" installation, you should have the "charsets.jar" file in <your_jdk_install_dir>\jre\lib (typically at C:\Program Files\jdk1.5.0). This jar contains the basic and extended charsets. 

However, this is not enough for it to work, since this file belongs to the "private" JRE installed by the JDK, and it is for use only by its tools. On the other hand, the public JRE can be used by other Java applications, and is contained outside the JDK (typically at C:\Program Files\Java\jre1.5.0).
(Source: http://java.sun.com/j2se/1.5.0/install-windows.html, Private vs. public JRE)

So the solution for me was to copy "charsets.jar" from the "private" JRE to the "public" JRE lib directory (tipically C:\Program Files\Java\jre1.5.0\lib). This made the extended international charsets available to my application.
Copying charsets.jar to my web application's lib directory didn't help, adding the lib directory to the classpath didn't either.

You may list the available charsets in your system this way:

  | 
  | import java.nio.charset.Charset;
  | 
  | Map<String, Charset> mapcharsets = Charset.availableCharsets();
  | printMap(mapcharsets, "Available Charsets:");
  | 
  | 	@SuppressWarnings("unchecked")
  | 	public static void printMap(Map map, String message) {
  | 	     System.out.println(message);
  | 	     Set entries = map.entrySet();
  | 	     Iterator iterator = entries.iterator();
  | 	     while (iterator.hasNext()) {
  | 	       Map.Entry entry = (Map.Entry)iterator.next();
  | 	       System.out.println(entry.getKey() + " : "
  | 	         + entry.getValue());
  | 	     }
  | 	     System.out.println();
  | 	}
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4122675#4122675

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4122675



More information about the jboss-user mailing list