0

I have a problem with the Maven project. When I want to use a special character, it returns '?'.

String text = "Hello World! ";
System.out.println(text);

Print console:

------------------------------------------------------------------------
Building Elliugh 1.0-SNAPSHOT
------------------------------------------------------------------------

--- exec-maven-plugin:1.2.1:exec (default-cli) @ Elliugh ---
Hello World! ?
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 0.612s
Finished at: Fri Jun 22 15:57:21 UYT 2018
Final Memory: 5M/243M
------------------------------------------------------------------------

In a "Java Application" project it returns well.

Print console:

Hello World! 
BUILD SUCCESSFUL (total time: 0 seconds)

PsD: I already changed pom.xml (add utf-8)

    <properties>
        <project.java.version>1.8</project.java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>${project.java.version}</source>
                    <target>${project.java.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>

I need help.

Thanks, Guillermo.

1 Answers1

0

Change the file encoding Netbeans uses. If for example you are on a Windows machine, the default encoding for the file will probably be cp1252, so unless you change it, special characters may not display correctly. See here for more information.

geco17
  • 5,152
  • 3
  • 21
  • 38