How to edit jar file in jd-gui

Namaste,

I used jd-gui from santoku linux where they pre-packaged it to reverse engineer mobile apps and other forensic purpose.

I tried to open jar contents and tried to modify the class file content and the jd-gui it not allowing me to edit the files.

Is it how jd-gui works or do I need to make any changes in the jd-gui.

Can you please suggest any alternative where I could modify class files and recompile back to apk (android package) files ?

Thanks,
Kiran.

Sometimes I need to know what’s inside to figure out a best solution, like modifying a Java .class file in a .jar file. After searching google and stack overflow for a while, I found this question is little cared, and almost all information is not complete. So I wrap them up and make the whole process runnable.

Use luyten (or JD GUI if you don’t care its bugs) to decompile the jar, and save all files to folder srcdir

Modify a java file, then compile it to .class file.

cd srcdir
vi com/.../A.java
cp some_folder/original.jar ./
javac -cp "original.jar" com/.../A.java

The last command will generate a file named A.class in the same folder as A.java

Use luyten to check if the file A.class is modified.

jar -uf original.jar com/.../A.class
mv original.jar modified.jar

This will generate a modified.jar. Use luyten to check again if it’s modified.

Note: If A.java depends other external jars other than original.jar, Add them to classpath by

javac -cp "original.jar;lib/*" com/.../A.java

It’s important to use lib/* rather than lib/*.jar because the later will not work.

  • Overview
  • Main Features

The “Java Decompiler project” aims to develop tools in order to decompile and analyze Java 5 “byte code” and the later versions.

JD-GUI is a standalone graphical utility that displays Java source codes of “.class” files. You can browse the reconstructed source code with the JD-GUI for instant access to methods and fields.

JD-Eclipse is a plug-in for the Eclipse platform. It allows you to display all the Java sources during your debugging process, even if you do not have them all.

JD-Core is a library that reconstructs Java source code from one or more “.class” files. JD-Core may be used to recover lost source code and explore the source of Java runtime libraries. New features of Java 5, such as annotations, generics or type “enum”, are supported. JD-GUI and JD-Eclipse include JD-Core library.

JD-Core, JD-GUI & JD-Eclipse are open source projects released under the GPLv3 License.

  • JD-Core and JD-GUI are written in Java.
  • JD-Core works with most current compilers including the following:
    • JDK 1.1.8, JDK 1.3.1, JDK 1.4.2, JDK 1.5.0, JDK 1.6.0, JDK 1.7.0, JDK 1.8.0, JDK 9.0.1, JDK 10.0.2
    • jrockit90_150_06
    • jikes-1.22
    • harmony-jdk-r533500
    • Eclipse Java Compiler v_677_R32x, 3.2.1 release
  • JD-GUI supports Drag and Drop.
  • JD-GUI supports CLASS, JAR, WAR, EAR, AAR, KAR, JMOD & ZIP files.
  • JD-GUI displays color coded Java source code.
  • JD-GUI allows you to browse the CLASS files and Java modules hierarchy.
  • JD-GUI lets you drag and drop LOG files, decompile CLASS files, and display the line of code that appears in Java stack traces.

  • Overview
  • Download

JD-GUI is a standalone graphical utility that displays Java source codes of “.class” files. You can browse the reconstructed source code with the JD-GUI for instant access to methods and fields.

Releases

  • Size : 3.09 MB

  • Size : 1.41 MB

  • Size : 1.28 MB

  • Size : 1.52 MB

  • Size : 1.30 MB

Release details & Old releases

Issues

Donations

Did JD-GUI help you to solve a critical situation? Do you use JD-Eclipse daily? What about making a donation?

  • Overview
  • Download

JD-Eclipse is a plug-in for the Eclipse platform. It allows you to display all the Java sources during your debugging process, even if you do not have them all.

Release

  • Size : 594 KB

Installation

  1. Download JD-Eclipse ZIP file,
  2. Launch Eclipse,
  3. Click on "Help > Install New Software...",
  4. Drag and drop ZIP file on dialog windows,
  5. Check "Java Decompiler Eclipse Plug-in",
  6. Click on "Next" and "Finish" buttons,
  7. A warning dialog windows appear because "org.jd.ide.eclipse.plugin_x.y.z.jar" is not signed. Click on "Install anyway" button.

Release details & Old releases

Issues

Donations

Did JD-GUI help you to solve a critical situation? Do you use JD-Eclipse daily? What about making a donation?

How do I open a JD GUI JAR file?

How to launch JD-GUI ?.
Double-click on "jd-gui-x.y.z.jar".
Double-click on "jd-gui.exe" application from Windows..
Double-click on "JD-GUI" application from Mac OSX..
Execute "java -jar jd-gui-x.y.z.jar" or "java -classpath jd-gui-x.y.z.jar org.jd.gui.App".

How do I edit a .JAR file?

To edit JAR file information in a data development project:.
Open a data development project in the Data Project Explorer..
Double-click a JAR file node in the JAR folder. The JAR file editor opens..
Edit the Java path information as required, and click File > Save..

How do I run a JAR file in Linux GUI?

Steps to run a JAR file on Windows, Mac or Linux.
Verify that Java is installed on your computer..
Confirm the computer's PATH variable includes Java's \bin directory..
Double-click the JAR file if auto-run has been configured..
Run the JAR file on the command line or terminal window if a double-clicking fails..

How do I decompile and edit a JAR file?

Before opening jar file just change the extension of jar to zip file and then extract that particular class file that you want to edit , then decompile it using any decompiler ,make the changes , compile it back and then finally put it back in the zip file. Hope it helps.