Text utf-8 in console works in eclipse, but fails to work with an exported jar

六眼飞鱼酱① 提交于 2020-01-24 20:59:34

问题


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


回答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.



来源:https://stackoverflow.com/questions/44503588/text-utf-8-in-console-works-in-eclipse-but-fails-to-work-with-an-exported-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!