Working with genrb and ICU4J

Wanting to use the messages in ICU4J, I was lead to believe one needed to run the command:

genrb root.txt

This produces root.res.
However using the following snippet results in the error message below:

UResourceBundle urb = UResourceBundle.getBundleInstance("Your package path","root");

>Data file yourPackagePath/root.res is corrupt - ICU data file error: Header authentication failed, please check if you have a valid ICU data file

then after some googling came across one entry in the mailing list that suggested I check the endian-ness.

Are you running generating the res file on a windows machine?
If yes you should run it through icuswap utility and make the res file 
big endian before you can load it in ICU4J.
Have a look at icu/source/tools/genrb/ for more information.

Best Regards,

Ram Viswanadha

Chris Hsu wrote:

> Hi;
> I am new to ICU4J. My understanding is that there is no Java tools to 
> generate ICU resource bundle file from .txt to .res. Then I use 
> genrb.exe from ICU4C. It generates .res file successfully. However, when 
> my java program tries to use the resource bundle it encountered the 
> following error.

It’s probably important to note that the icuswap utility looks to be discontinued.

Anyways to fix this issue you need to do icupkg -tb root.res if using ICU4J when root.res was generated on windows.