IKVM system properties not found

572 Views Asked by At

How do I set system properties for raw Java classes used from C# code through IKVM?

I am dealing with some Java code that has been ported to C# using IKVM. Some of the classes have been wrapped in C# classes, but not all of the Java API yet. So I have two versions of some classes, and because only a small part of the API has been wrapped, I have to use the raw Java classes directly in my C# code.

When I use the C# wrapped version, I can parse UTF-8 encoded XML files correctly. When I try to use the underlying Java class directly, I get parsing errors ("content not allowed in prolog") which indicate the wrong charset is being used to parse.

In Java we solve encoding issues by setting -Dfile.encoding=UTF-8, and I am trying to do the same in C# as follows:

    static FeedSample()
    {
        java.lang.System.setProperty("file.encoding", "UTF-8");
    }

This setting is picked up when I use the C# wrapper class. When I use the underlying Java class directly, the system property is not picked up. I think I am missing something obvious here. I also tried putting -Dfile.encoding as a command line argument but that did not help.

0

There are 0 best solutions below