Skip to main content

UTF gone?

1 reply [Last post]
mcasspj
Offline
Joined: 2013-01-02
Points: 0

Hi All
I'm very new to java so be gentle :-)
Over Christmas I wrote a little self test desktop application for Chinese vocabulary.
I'm using Netbeans 7.3 beta 2 and all is fine.
I can clearly see simplified chinese characters as next: 帮

However if I try to run it from the jar
C:\Users\mcasspj.DS\Documents\NetBeansProjects>java -jar .\Chinese1\dist\Chinese1.jar
it doesn't seem to recognise UTF and instead of Chinese characters I get: å��一æ"ˆ
Note the two characters are not necessarily the representation just examples.
The OS is Windows 7 and the version of java
C:\Users\mcasspj.DS\Documents\NetBeansProjects>java -version
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)

I know Netbeans 7.3 is in beta but don't think that is where the problem is.
It's a javafx application and my layout file should use utf-8 as shown by the first line as below.
<?xml version="1.0" encoding="UTF-8"?>

Cheers Paul

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mcasspj
Offline
Joined: 2013-01-02
Points: 0

Finally sorted it!
Basically Windows was overriding the file encoding and not using utf8
See http://stackoverflow.com/questions/1336930/how-do-you-specify-a-java-fil...

C:\Users\mcasspj\Documents\NetBeansProjects\Chinese1\dist>java -Dfile.encoding=utf8 -jar Chinese1.jar

Works a treat.

Paul