Search code examples
mavenutfexec-maven-plugin

How to set the file.encoding property at exec-maven-plugin?


I trying to exec my standalone application via exec-maven-plugin, but it started with WIN encoding, not UTF-8. I read about Java command line key -Dfile.encoding=UTF-8. How to set this property to my application? Thanx.

maven pom:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <configuration>
                <executable>java</executable>
                <mainClass>my.main.Class</mainClass>
            </configuration>                
        </plugin>

Solution

  • According to the exec-maven-plugin documentation, it should look like this:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <configuration>
                <mainClass>my.main.Class</mainClass>
                <commandlineArgs>-Dfile.encoding=UTF-8</commandlineArgs>
            </configuration>                
        </plugin>