Disassembling Java classes is easy, so perhaps I’d need to encrypt all my classes? And when the main program (which is not encrypted) starts, it decrypts all the classes and uses them, and when the program ends a cleanup-thread will place the files back into their original state.
Through then the main program needs to know the code. Which can be disassembled again.
So is there a proper way to protect your code?