The invention discloses a method for encrypting and protecting Java application software, which is more strict and reliable, and is realized by packaging an agent class loader. Precisely, by a special agent class which is executed when a modified Java virtual machine starts, a customized binary encryption and decryption native code base is loaded by a JavaNativeInterface or JavaNativeAccess mode, so that the encryption and decryption operations of a random self-defined rule to the byte codes of target Java application software can be realized. According to the invention, the problem that for so long, because the byte codes can be decompiled and restored into source program codes, the application software which is programmed by adopting Java can not be prevented from being cracked and pirated is solved, and the problem that a Java obfuscator only obfuscates codes, so that the readability of source codes generated by decompiling is reduced, but the decompiling can not be thoroughly prevented is solved. The method disclosed by the invention can be widely applied to the protection of the application software which is developed on the basis of a JavaSE/JavaEE standard, supports theWindows/Linux/Nuix operating system environment, and can greatly improve the copyright protection capability of the Java application software.