2

I have a program that writes text data to files. When I run it from netbeans the files are in a correct encoding and you can read them with a notepad. When I run it from cmd using java -cp ....jar the encoding is different.

What may be the issue??

ps. I've checked that the jre. versions are the same that executes (v 1.8.0_31)

ApollonDigital
  • 913
  • 3
  • 15
  • 24

1 Answers1

1

Netbeans startup scripts may specify a different encoding than your system default. You can check in your netbeans.conf.

You can set the file.encoding property when invoking java. For example, java -Dfile.encoding=UTF8 -cp... jar.

If you do not want to be surprised when running your code on different environments, even better solution would be to specify the encoding in your source code.

Further reading:

Community
  • 1
  • 1
mzc
  • 3,265
  • 1
  • 20
  • 25