How to obfuscation and compress the j2_package in eclipse

Source: Internet
Author: User

Java is an explanatory language, and the generated class files are easily decompiled. Therefore, the jar packages produced by the Java program must be obfuscated. Today we use the most common proguard for obfuscation and compression.

I am using myeclipse and eclipseme plug-in for the development of j2s. It has its own support for proguard, download proguard 4.3 to the local machine, and decompress it.

Configure proguard in eclipse for obfuscation compilation as follows:

1. Select the preference in the eclipse Window menu.
2. Open the j2_option branch on the left panel, select the packaging subitem, and click "obfuscation ).
3. Configure the root directory of proguard (at the top of the dialog box ).
4. Configure the proguard option as needed below. For more information about proguard, see proguard's SourceForge site.
Note for Microsoft Windows users: by default, proguard assumes that the operating system you are using can distinguish two file names that are case-insensitive (for example,. java and. java is considered to be two different files ). Obviously, Microsoft Windows is not such an operating system (Windows is case-insensitive to file names ). Therefore, Windows users must specify the-dontusemixedcaseclassnames option for progurad. If you do not do this and your project contains more than 26 classes, proguard will use case-insensitive file names by default, and cause the class files to overwrite each other. For security reasons, starting from version 0.9.0, eclipseme sets the-dontusemixedcaseclassnames option for proguard by default. Many Unix users in the project can delete this option, so that the size of the generated JAR file can be further reduced.

5. Set the window as follows:

6. Right-click the project and find the following options for mixed Compilation:

 

In the deploy folder, we can see the generated project JAR file and some other files generated by proguard, when the jar package is unbundled, it can be seen that all the other classes except the MIDlet class are obfuscated into A, B, C, D, and other classes. The size of the jar package is significantly reduced.

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.