-
Type:
Bug
-
Status: Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 8.2, 9.0
-
Fix Version/s: None
-
Component/s: core, projects - Maven
-
Labels:None
-
Environment:The behaviour was reproduced under Ubuntu and MacOS both with NB 8.2 and 9.0
I'm using Java's build-in class java.util.Scanner to read keyboard input (typed in within Netbeans' Output window).
To accomplish this task a simple Java class is used:
package de.szott; import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.println("output some non ASCII chars works properly: ä ö ü ß"); System.out.print("give me some non ASCII chars, e.g. German umlauts: "); Scanner input = new Scanner(System.in, "UTF-8"); System.out.println("input: " + input.nextLine()); input.close(); } }
Running this class in Netbeans as a Java project leads to the expected result:
run: output some non ASCII chars works properly: ä ö ü ß give me some non ASCII chars, e.g. German umlauts: äöü input: äöü
Running the same class as a Maven project in Netbeans (which uses the Maven Exec Plugin internally) leads to erroneous behaviour:
[INFO] --- exec-maven-plugin:1.5.0:exec (default-cli) @ Bug --- output some non ASCII chars works properly: ä ö ü ß give me some non ASCII chars, e.g. German umlauts: äöü input: ���
Netbeans IDE is running under Ubuntu 64Bit. Netbeans is using UTF-8 as default encoding. The Maven project consists of the following pom.xml:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>de.szott</groupId> <artifactId>UmlautTestWithMaven</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> </project>
The output � (Unicode replacement character) indicates that the interpretation of the input bytes as UTF-8 encoded is not appropriate. This confirms that Netbeans or the Maven plugin in Netbeans does not provide keyboard input in UTF-8 encoding to the running Java application.
A minor change to the simple program indicates that Netbeans seems to interpret the keyboard input as ISO-8859-1 encoded when running as a Maven project:
Scanner input = new Scanner(System.in, "ISO-8859-1");
Output (when running as a Maven project):
[INFO] --- exec-maven-plugin:1.5.0:exec (default-cli) @ Bug --- output some non ASCII chars works properly: ä ö ü ß give me some non ASCII chars, e.g. German umlauts: äöü input: äöü
Note that this approach does not work if characters are provided as input that cannot be encoded in ISO-8859-1, e.g. the € character.
This indicates that the Maven plugin in Netbeans does not provide full Unicode support.
Please note that the problem cannot be reproduced when running the program via Maven's exec plugin outside of NetBeans.