Skip to main content

NullPointerException thrown by java.nio.charset.Charset.put

No replies
balteo
Offline
Joined: 2003-06-11
Points: 0

Hello,
The following test case throws an NPE when run in our maven project.
package pack;

</pre>
<pre>import java.nio.charset.Charset;

import java.util.Iterator;
import java.util.Set;
</pre>
<pre>public class TestCase {

    public static void main(String[] args) {
        Set set = Charset.availableCharsets().keySet();
        for (Iterator iterator = set.iterator(); iterator.hasNext();) {
            String s = (String) iterator.next();
            System.out.println(s);
        }
    }
}

Here is the stacktrace:

Exception in thread "main" java.lang.NullPointerException
at java.nio.charset.Charset.put(Charset.java:550)
at java.nio.charset.Charset.access$300(Charset.java:276)
at java.nio.charset.Charset$4.run(Charset.java:593)
at java.nio.charset.Charset$4.run(Charset.java:585)
at java.security.AccessController.doPrivileged(Native Method)
at java.nio.charset.Charset.availableCharsets(Charset.java:584)
at pack.TestCase.main(TestCase.java:9)

However, when we run the project as a separate project, it runs fine.

Does anyone have any clue as to how to fix this error?

Thanks in advance,

JM