Monday, 2 September 2013

Java sending UTF-8 characters after compiled to Jar not working

Java sending UTF-8 characters after compiled to Jar not working

This is really strange, when i am running my application from within
NetBeans everything works fine. However when i build the app into a Jar
and run it from the Jar the following code converts characters like ä, ö,
å to ?
String string = "{\"id\":1,\"type\":\"" + methoden + "\",\"message\":\"" +
msget + "\"}";
PrintWriter pw = new PrintWriter(os);
pw.println(string);
pw.flush();
In the above example the String msget = "Hej där, vad händer"
When i console.log this on the server i get: {"id":"1", "type":message,
"message": "Hej d?r, vad h?nder "}
Again, this does only happend when i compile my app into a Jar.
Any ideas what is going on?

No comments:

Post a Comment