Setting the default Java character encoding

后端 未结 17 1716
终归单人心
终归单人心 2020-11-21 06:09

How do I properly set the default character encoding used by the JVM (1.5.x) programmatically?

I have read that -Dfile.encoding=whatever used to be the

17条回答
  •  终归单人心
    2020-11-21 06:55

    In case you are using Spring Boot and want to pass the argument file.encoding in JVM you have to run it like that:

    mvn spring-boot:run -Drun.jvmArguments="-Dfile.encoding=UTF-8"
    

    this was needed for us since we were using JTwig templates and the operating system had ANSI_X3.4-1968 that we found out through System.out.println(System.getProperty("file.encoding"));

    Hope this helps someone!

提交回复
热议问题