Skip to content

Need to specify -Dfile.encoding when executing jar created by Warbler #368

Description

@rob99

I have a simple script that reads a XML file and writes a CSV file. My scripts all have #encoding:utf-8 at the top and I explicitly set the external encoding on all reads and writes as UTF-8.

Everything works as expected.

I packaged my script using Warbler and deployed it to the network for my colleagues. Unfortunately the CSV files being generated by the packaged jar were incorrect -- various non-ASCII characters were being munged.

It took me a while to work out that the fix was to specify the file.encoding as a JVM option. E.g.

java -Dfile.encoding=UTF-8 -jar myscript.jar 

In other words, there was differing behavior between my raw (j)ruby script and the Warbler package of same.

I'm not sure if this is a bug in Warbler, or JRuby, or not a bug at all, but I thought I'd post this here for discussion and in case somebody else has the same problem.

Luckily for me, I wanted UTF-8 all around. I don't know what I would do if I wanted a mixture of encodings among source files, input file and output file. Ruby would allow this, but how would I set file.encoding?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions