Demo: 2. Modify the Class file

July 2025

  1. Unzip a WAR file

  2. Decompile class files using Procyon

  3. Edit Java source directly and deploy (with expected errors)

  4. Modify class files using a Java class editor (without recompiling) and deploy successfully


🧩 1. Unzip the WAR File

To inspect or modify the contents of a WAR file:

jar -xvf ../demo.war

Or use any archive tool like 7-Zip or WinRAR to extract it.


🔍 2. Decompile Class Files Using Procyon

Procyon is a powerful Java decompiler. To use it:

  1. Download the Procyon CLI jar from GitHub.

  2. Run the decompiler:

java -jar procyon-decompiler.jar Demo2App.class > Demo2App.java
The decomplied coding is different from the orginal version

⚠️ 3. Directly Edit Class File and Deploy (With Errors)

If you edit the Java .class file directly and try to repackage and deploy without recompiling:

  1. Modify the .java file (e.g., change the message in Demo2App.getMessage()).

  2. Repackage the WAR (without compiling):

jar -cvf demo.war *
  1. Deploy to Tomcat by copying the WAR to the webapps/ folder.

🛑 This will fail because Tomcat runs .class files, and your .java edits are ignored unless recompiled.


🛠️ 4. Edit Using a Java Class Editor (Without Recompiling)

To modify behaviour without source code or recompilation:

  1. Open Demo2App.class

  2. Locate the incorrect URL

  1. Modify the return string in the bytecode.

  2. Save the .class file and repackage the WAR:

jar -cvf Demo.war *
  1. Deploy to Tomcat again — this time it works without compilation errors.

  2. The problem is fixed


Last updated

Was this helpful?