Solution to garbled code in java using jar package:
1. Modify the default encoding of text files in Eclipse: windows->Preferences->general->Workspace ->Text file encoding is set to UTF-8.
Modify the default encoding of JAVA source files: windows->Preferences->general->Content Types->Context Types tree on the right, click on Text, select Java Source File, and click Default below Enter UTF-8 in the encoding input box and click Update.
Remember to restart eclipse after the last modification, it will take effect after restarting.
2. Just add encoding when referencing the jar package
java -Dfile.encoding=utf-8 -jar demo.jar
Please follow us for more java knowledgejavaBasic Tutorial column.
The above is the detailed content of Solution to garbled code when using jar package in java. For more information, please follow other related articles on the PHP Chinese website!