Java application after packaging need to pay attention to coding problems _java

Source: Internet
Author: User
Tags md5

Recently in a project, the overall project is to deal with the database, take out data to be submitted to an interface through the HTTP protocol. The specific function is not much to say, just talk about the inside of a point--coding problems

In the project, it involves taking the MD5 value of all the data.

In Java projects, individuals prefer to change the project's default encoding to UTF-8. The development tools used are primarily eclipse. However, strange problems have arisen. When I debug my project in the IDE, there's no problem, but after I hit the jar package, I passed

Java-jar Project.jar

When running, each time the data is submitted, the interface will return the data saying that my signature is incorrect. In other words, it's my last step, and it's a problem when I do MD5 operations.

Why not just hit the jar bag? After several twists and turns, but also to see the parameters of the hashcode, but also to check all the submitted content of the hexadecimal data, found that the text encoding the problem. is correct in Eclipse, but the startup command line has not set the string default encoding after the jar package is played, so the Java virtual machine runs according to the default encoding of the system in which it resides. I'm using the Windows environment, so naturally it's GBK encoded.

Later, by consulting the data, the solution is to add a parameter to specify the encoding:

Java-dfile.encoding=utf-8-jar Project.jar

That's it. The tool is running properly.

Thank you for reading, I hope to help you, thank you for your support for this site!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.