Apr 23, 2015

Apache Commons CLI not working? No, it's a junk character problem

I am using Apache command line interface to accept run time parameters.



While in my code, I am using -t to specify run time topology name.
But to my surprise, it didn't work. I took 2 hours to debug this problem and finally by chance I compare the result and find our that

It's complaining about the - character. What is wrong with it?


I used Notepad++ and there is good plugin called HexEditor and it gives our the answer



This is causing strange problem.

You may ask why. This is because when someone sent me the command from Outlook, it was already junked. 
OK. the lesson and learn here is to be careful of the characters you pasted from Outlook, especially when it's in Chinese environment. We may try to type the command again to avoid problems.

If you find this article is useful, please click the ads on this page to help. Thank you very much.