Avoid Java encoding errors that occur when running FitGen.exe on Japanese Windows

TL;DR Set the environment variable JAVA_TOOL_OPTIONS to -Dfile.encoding = UTF-8.

環境変数_JAVA_TOOL_OPTIONS.PNG

Details

If you have defined a custom message etc. in GARMIN FIT SDK, you need to execute FitGen.exe to generate FIT SDK. https://developer.garmin.com/fit/cookbook/fitgen/

However, the document comment of EventMesg.java of FIT SDK recently distributed by Garmin Developers contains a mysterious garbled character, and when FitGen.exe is executed as it is

> .\FitGen.exe -o test -java
FIT Code Generator - Protocol 2.00  Profile 21.40Release
SDK Version: production/akw/21.40.00-0-g813c158
Parsing existing config.csv...
Writing new config.csv...
Generating Java code...
Building Java tools...0%
com\garmin\fit\EventMesg.java:679:error:This character cannot be mapped to encoding MS932
     * Comment:The Tetsu?first tetsu?byte?is tetsu?the tetsu?radar_threat_level_max, the tetsu?second tetsu?byte?is tetsu?the tetsu?radar_threat_count, and the tetsu?last tetsu?16?bits?are tetsu?reserved?for Tetsu?future?use?and tetsu?should?be tetsu?set?to Tetsu?FFFF.
                     ^
The following is omitted

Error occurs and the build fails.

The error This character cannot be mapped to encoding MS932 can be avoided by passing an appropriate encoding such as UTF-8 to javac. This can be avoided by passing the following options.

javac -encoding UTF-8 EventMesg.java

However, in the case of FitGen.exe, the javac call part is done inside FitGen.exe, so you cannot pass options directly to javac.

Therefore, you can avoid the error by adding JAVA_TOOL_OPTIONS to the user environment variable of Windows that executes FitGen.exe and specifying the option you want to pass to javac.

https://docs.oracle.com/javase/jp/8/docs/technotes/guides/troubleshoot/envvars002.html https://qiita.com/n_slender/items/6c566bb345e844ba8127

Recommended Posts

Avoid Java encoding errors that occur when running FitGen.exe on Japanese Windows
Notes on errors that occur when installing the JDK and countermeasures that I have tried
Ruby on Rails Tutorial Troublesome notes when running on Windows
Resolve CreateProcess error = 206 when running Java in a Windows environment
Solution for errors that occur when upgrading to Rails 5.2 series
Links that I referred to before running Elasticsearch 7.7 on Java 11
Show detailed error in Logger when running Java on server
Notes on character encoding when migrating from windows to Mac
Change java encoding in windows