Michael Hegner Michael Hegner - 8 months ago 84
reST (reStructuredText) Question

Spring-Boot executable encoding

My Rest-Application delivers data in correct encoding when running under Eclipse. But when I start the application as executable jar on a Windows System, my special characters are broken.

What am I missing?

enter image description here



edited a couple time after some tests

Eclipse's encoding is set in preferences->general->workspace, which whould by default be inherited from the OS (cp1250 on windows). When you create a "Run as" task, it also stores it. So if you update eclipse's setting, make sure you re-create your "run as" task. You can see the actual value used when launching your application: Run configurations... -> Your Run task -> Common tab.

You can also force an encoding in eclipse.ini by adding -Dfile.encoding=AnotherEncoding at the end.

Command line

When launching from the command line, it takes the system default value, which would be cp1250 on whidows.

You could print the encoding at the very first line of your program, just to see: System.out.println(System.getProperty("file.encoding"));

To specify an encoding from the command line: java -Dfile.encoding=UTF-8 yourApp.jar

See also

Take a look at this too: http://stackoverflow.com/a/14867904/641627

This indicates a problem with your code. Your code is currently depending on the default platform encoding, and doesn't work if that encoding is not "UTF-8". therefore, you should change the places in your code which depend on the default platform encoding to use the "UTF-8" encoding explicitly.