Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-6115

UTF-8 input is broken in Maven project

VotersWatch issueWatchersLinkUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 12.3, 12.4, 12.5
    • 12.6
    • apisupport - Maven
    • Linux Manjaro

      Netbeans 12.5 (but the same problem is in earlier versions too)

      Maven 3.8.2

      Java - tried with 8,14,17 

       

    Description

      Trying to get user input containing 'special characters' like ščřžýáíé doesn't work in Maven project:

       

      Scanner sc = new Scanner(System.in, "UTF-8");
      System.out.println("Enter text: ");
      String text = sc.nextLine();
      System.out.println("You have entered: " + text);
       
      

       

       

      In Netbeans this code will fail printing what you entered if you enter something like 'český, řeka etc...' but works ok with any input not containing these characters

      Same code works in an Ant project without any problems.

      It also works on command line by copying and pasting the command from Netbeans output window (and replacing the double quotes with single quotes). 

      Example:

      cd /home/atrament/Nextcloud/Projects/java/InputTestMaven; JAVA_HOME=/opt/java/jdk-14.0.1+7-hotspot M2_HOME=/opt/maven /opt/maven/bin/mvn -Dexec.vmArgs= "-Dexec.args=${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}" -Dexec.appArgs= -Dexec.mainClass=net.atramentovo.inputtestmaven.Main -Dexec.executable=/opt/java/jdk-14.0.1+7-hotspot/bin/java -Dfile.encoding=UTF-8 org.codehaus.mojo:exec-maven-plugin:3.0.0:exec
      Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
      Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
      Scanning for projects...-------------------< net.atramentovo:InputTestMaven >-------------------
      Building InputTestMaven 0.1
      --------------------------------[ jar ]------------------------------------ exec-maven-plugin:3.0.0:exec (default-cli) @ InputTestMaven ---
      Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
      Enter text: 
      Řeka šuměla skalnatým údolím
      You have entered: Xeka aumla skalnat�m �dol�m
      ------------------------------------------------------------------------
      BUILD SUCCESS
      ------------------------------------------------------------------------
      Total time:  2.682 s
      Finished at: 2021-10-10T19:55:24+01:00
      ------------------------------------------------------------------------
      

       

       

       

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            Atrament Vladimir Machat
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h
                1h

                Slack

                  Issue deployment