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.