System.out.println(Charset.defaultCharset().displayName()); prints ISO-8859-1, so I want to set the defaultCharset to UTF-8.
When tried with java -Dfile.encoding=utf-8 -jar XXX.jar, I checked that default charset is set to UTF-8.
But is there a way to set Dfile.encoding=utf-8 option at maven packaging level, so that I can just run java -jar XXX.jar?
What I tried:
mvn clean package -Dfile.encoding=utf-8pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<argLine>-Dfile.encoding=utf-8</argLine>
</configuration>
</plugin>
MAVEN_OPTS="-Dfile.encoding=utf-8" mvn clean package
I prefer controlling with pom.xml file.