控制台中的文本utf-8可以在Eclipse中使用,但无法与导出的jar一起使用 [英] Text utf-8 in console works in eclipse, but fails to work with an exported jar

查看:93
本文介绍了控制台中的文本utf-8可以在Eclipse中使用,但无法与导出的jar一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Java应用程序,但在输出,文件,控制台等方面遇到了一些问题

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

关于文件,我想出了如何正确使用utf -8,但是我不知道要在控制台中设置编码。

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.

这是一个简单的测试,我在日食中使用它,然后生成一个jar,然后使用.bat文件执行它。

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");
    }
}

这是我使用此命令执行Jar时的结果蝙蝠文件:

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

结果:

InitilaisÚe la procÚdure

在我的日食配置中,我一般是->工作区,在文本文件中编码为UTF-8

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

推荐答案

可能是Java版本负责。不同的Java版本在Eclipse中可能都显示相同的结果,但是从Windows命令行运行时将显示不同的结果。

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.

下面是Windows控制台的输出(此命令是从运行64位Windows 7的计算机上获得的。)

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

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

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

使用较新版本的Java在自己的计算机上进行测试,看看是否可以解决问题。这样至少可以确定问题出在您的Java版本还是Windows命令行控制台。

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.

这篇关于控制台中的文本utf-8可以在Eclipse中使用,但无法与导出的jar一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆