Intellij build artifact - runnable jar UTF-8

542 Views Asked by At

I builded a project that reads a csv file (saved as csv UTF-8). in my project i read every line of that csv file. The output of every line is displayed in a log file.

Now when i run my project in intellij and i look into the log file all the lines are readable. But when i build an artifact from my project and then run that jar some symbols that are in the csv are replaced by a '?' symbol ..

i looked into the settings of my project under file encoding and there is everything UTF-8 also.

I have no clue how that is possible .. Can anyone help me out ? Thx !

2

There are 2 best solutions below

0
On BEST ANSWER

Specify the encoding when running the app from the command line like this:

java -Dfile.encoding=UTF-8 -jar yourapp.jar param1 param2

Or change your app code that reads/writes files to explicitly force the correct encoding.

0
On

When I specify -Dfile.encoding=UTF-8, I need to put this encoding option between two " however it doesn't work and an error is returned. Maybe it will help somebody with the same problem as me.

java "-Dfile.encoding=UTF-8" -jar app.jar