drools规则出现中文验证 与jvm 默认编码(The default charset is determined during virtual-machine)的关系很重要
来源:互联网 发布:2016淘宝最大的店铺 编辑:程序博客网 时间:2024/06/05 17:10
drools规则出现中文验证 与jvm 默认编码(The default charset is determined during virtual-machine)的关系很重要
java.nio.charset.Charset类中有一个静态变量:
The default charset is determined during virtual-machine startup and typically depends upon the locale and charset of the underlying operating system.
Charset
类,看到jvm默认的编码对规则校验的失灵发生。service mysql start
方式启动自己的java 应用也会出现编码问题。
Java uses a native call to list the contents of a directory. The underlying C runtime relies on the locale concept to build Java String
s from the byte blob stored by the filesystem as the filename.
When you execute a Java program from a shell (either as a privileged user or an unprivileged one) it carries an environment made of variables. The variable LANG
is read to transcode the stream of bytes to a Java String, and by default on Ubuntu it's associated to the UTF-8 encoding.
Note that a process need not to be run from any shell, but looking at the code it seems that Upstart is smart enough to understand when the command in the configuration file is intended to be executed from a shell. So, assuming that the JVM is invoked through a shell, the problem is that the variable LANG
is not set, so the C runtime assumes a default charset, which happens to not beUTF-8. The solution is in the Upstart stanza:
description "List UTF-8 encoded filenames"author "Raffaele Sgarro"env LANG=en_US.UTF-8script cd /workspace java -jar list.jar test > log.txtend script
I used en_US.UTF-8
as the locale, but any UTF-8 backed one will do just as well. The sources of the test list.jar
public static void main(String[] args) { for (File file : new File(args[0]).listFiles()) { System.out.println(file.getName()); }}
The directory /workspace/test
contains filenames like ààà
, èèè
and so on. Now you can move to the database part ;)
- drools规则出现中文验证 与jvm 默认编码(The default charset is determined during virtual-machine)的关系很重要
- How do I change the Java Virtual Machine (JVM) that MATLAB is using?
- The virtual machine 'xxx' has terminated unexpectedly during startup with
- Hadoop启动时出现Unrecognized option: -jvm 和 Could not create the Java virtual machine.
- Hadoop启动时出现Unrecognized option: -jvm 和 Could not create the Java virtual machine.
- 关于打开Eclipse时出现eclipse failed to create the java virtual machine与locking is not possible in the direc
- 浅谈jvm-Java虚拟机( Virtual Machine)
- VMware6关机后出现is not a valid virtual machine configuration file的解决办法
- 转:hadoop启动问题(Unrecognized option: -jvm Could not create the Java virtual machine.)
- 解决MyEclipse 6.5启动出现的Could not create the Java virtual machine问题
- 关于 JDeveloper 出现 unable to create an instance of the java virtual machine 错误的解决办法
- 打开Eclipse时出现"Failed to create the Java Virtual Machine" 的处理
- 打开eclipse时出现 failed to create the Java Virtual Machine的错误
- Eclipse启动时出现:failed to create the java virtual machine问题的解决办法
- 打开Flex4.6时出现了Failed to create the Java Virtual Machine的解决方法
- 下载ADT,打开里面的Eclipse出现failed to create the java virtual machine解决办法
- Eclipse初次启动时出现Failed to create the Java Virtual Machine的解决方案
- android开发中出现“Failed to create the Java Virtual Machine”时的解决方法
- C语言简介,gcc编译器,gcc使用方法
- C# DataGridView控件清空数据完美解决方法
- 进程间通信总结 && IPC主题三之 共享内存
- kotlin
- ajax传递参数
- drools规则出现中文验证 与jvm 默认编码(The default charset is determined during virtual-machine)的关系很重要
- 脚本
- 图-深度优先广度优先,以及邻接表的创建
- react native navigation 参数传递调用
- Guava之消息处理机制
- Thinkphp5学习(21)关联:一对一
- windows下安装TensorFlow(Win8 + Anaconda4.4 <python3.6>)
- C++学习:面向对象之继承
- js上拉加载