0

I have a problem with the chars of all JTextField on my program (when compiled into JAR). When I run it from Eclipse everything works fine... the problem is when run from the already compiled JAR.

The problem is, when I insert text to JTextField with special character as "Ñandú?" when java extract text from the input that goes with rare characters. For example: System.out.println( myTextField.getText() );. That would write in the console: IMAGE

I have tried all kinds of way to switch chars, but when I write again on the console or in the interface reappear rare signs. I've even tried the library Commons Lang 3.1, but I have not been successful :(

I hope someone knows what to do! The only way to work is inserting -Dfile.encoding=UTF-8 on running the jar file, but that can not be so.

Sorry for the English. Thanks!!!

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Gabriel
  • 5
  • 1
  • 4

1 Answers1

0

Java uses the default encoding for your computer, which for Windows would be C16 and doesn't support unicode. Run your program with the following command in terminal:

java -jar -Dfile.encoding=utf-8 <path to your .jar>

Eclipse would run your applications like so if you have any unicode in your document, but outside of it, you're on your own.

The only other possible way I can think of is writing a .bat script with this command and putting it in the same folder as the application.

Alex
  • 73
  • 1
  • 8