1

I'm developping a java application, and I get some problems with Output, files, console,

So about the files I figure out how to right using utf-8, but I can't figure out to set the encoding in the console.

This is a simple test that I use it in my eclipse, then I generate a jar, and I execute it using a .bat file.

public class Test {

    public static void main(String[] args) {
        System.out.println("Initialisée la procédure");
    }
}

This is the result when I execute my Jar using this bat file:

"C:\Program Files (x86)\Java\jre7\bin\java" -Xms512m -Xmx512m -jar myapp.jar
cmd

Result:

InitilaisÚe la procÚdure

In my eclipse configuration I have in General --> Workspace, in Text file encoding UTF-8

Yacino
  • 645
  • 2
  • 10
  • 32
  • Your code is not the problem. The default code page of the Windows command window does not support most Unicode characters. See https://stackoverflow.com/questions/54952/java-utf-8-and-windows-console. – VGR Jun 12 '17 at 16:45
  • Thanks @VGR, I already tried to use -Dfile.encoding=UTF-8 but I get this result: "Initialis├®e la proc├®dure". And the chcp 65001 && start.bat given nothing – Yacino Jun 12 '17 at 16:52

1 Answers1

1

It is possible that the Java version is responsible. Different Java versions may all show the same results in Eclipse, but will show different results when run from the Windows command line.

Below is the output from the Windows console (this is from a computer running 64-bit Windows 7).

Result for Java 7:

java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

InitialisΘe la procΘdure

Result for Java 8:

java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)

Initialisée la procédure

Test it out on your own computer with a more recent version of Java to see if that fixes the problem. That will at least identify if the issue is with your Java version or the Windows command line console.

JonathanDavidArndt
  • 2,518
  • 13
  • 37
  • 49
  • Thanks, yes it works well using Java version 1.8.0_72, but I can't still understand why Java version 1.7 give this issue. – Yacino Jun 16 '17 at 07:41
  • And I don't see anything specifically related to this issue in the Java release notes. There are constant changes being made to the Java platform (at the time of this writing, version 8u131 is the most current). If we were really interested in narrowing down the culprit, we could run this program with each release of Java before 8u72 and see when it breaks. – JonathanDavidArndt Jun 16 '17 at 13:14