First, preparatory work
Tools: Jd-gui anti-compiler tool
Download Address: https://github.com/java-decompiler/jd-gui/releases
Here I use the Mac, so directly download the latest version of Jd-gui-osx-1.4.0.tar as a demo, window system can download Jd-gui-windows-1.4.0.zip Two, operation steps
1, will download the finished tar file double-click Decompression Open, and then double-click Jd-gui.app Open Software, the interface is as follows
2, click on the top left corner of the folder icon, directly select the jar package path open jar file can see the jar package structure and class compiled files, the interface is as follows
3. Then copy the class that needs to be changed, paste it into a Java file, and edit the file as you need it.
4, open the terminal window, use Javac to perform this class or other way to regain the class file
5, the generated class file and the original jar package first placed in the same directory, and CD to the directory
6, take my operation for example jar package for Mxfingerdriver.jar, changed class file for Usbbase.class
Execute the following command:
This command creates the same folder as the original Jar package path (that is, the package name of the class file in the jar package)
mkdir-p org/zz/mxhidfingerdriver
// Copy a modified Usbbase.class file from the current directory to the Mxhidfingerdriver folder under
cp usbbase.class org/zz/mxhidfingerdriver/
// Add/update file Usbbase.class to existing jar file Mxfingerdriver.jar
jar uf Mxfingerdriver.jar org/zz/mxhidfingerdriver/ Usbbase.class
7, here is done, do not trust the words can be guided into the GUI tool to see if the changes are successful. iii. problems that may be encountered
1, Mac default is not allowed to open the software is not approved, so the installation of the Jd-gui tool may not be installed normally, at this time we need to go to the preferences set permissions, open the Preferences pane, double-click Security and privacy into
If you see the following "any source", select it (you need to first use the administrator password to solve the lower left corner of the small lock)
If there is no "any source" option, then the system defaults to hide, we need to open the terminal with the command line set
The following commands are executed:
sudo spctl --master-disable
Note that there are two in front of master--the tutorial on the Internet search is that there is one less always fail.
Press ENTER, and then enter the administrator password. So the "any source" option is back.
Note: If the option to allow the app Store and the approved developer app to be reopened in the "Security and privacy" of system preferences, that is, once you reopen gatekeeper, the options for "any source" app will disappear again, and you can run the command again to turn off gatekeeper.
2, Operation step 4, when you get the class file, you may have an error, the compiler does not past the
encountered this problem to see the error log, most of the class has relied on Android library files (such as intent, context) or the jar package itself, some files (such as the tool class in the JAR package) If you're relying on Android's library files, we can put this class into an Android project to generate a class file (according to the class in the jar package to create the package name, avoid unnecessary trouble)
If it is some class file of the jar package itself, you can observe whether it is useful, if there is no actual effect, You can delete it again, and if it works, it might be a hassle, and it's best to make the developer of the jar package change itself.