简体   繁体   中英

jar edit and re-compile in simple way

I have a jar file called ScreenCapture.jar

I use http://jd.benow.ca/ what is in there. I have even downloaded jd-gui

This is what it shows me

抓屏

I can see the ScreenCapture.class file. I want to edit 2 lines here

      Thread.sleep(15000L);
      to
      Thread.sleep(60000L);

and

driver.manage().window().setSize(new Dimension(1024, 768));
to
driver.manage().window().setSize(new Dimension(1200, 800));

But this file is not editable.

My question is, how to edit it? like how to decompile it so I can edit it and then recompile it. So I can just re-upload my jar file and everything gets back to normal?

Btw, I know nothing about java, and I don't have any special application/software installed on my machine

follow these steps:

  1. Create an eclipse project
  2. add the jar as a dependency to that project
  3. Create a new class named ScreenCapture.java in the package screencapture.
  4. copy the whole source from your JD too view the screenshot of which u attached here.
  5. change the code which u want.
  6. build the project
  7. check the bin folder of you eclipse project . this will have the new compiled .class file.
  8. open the jar in winrar and copy the .class file from bin folder into your jar.
  9. and you are done.

Save the source files by clicking save menu item under file. It will generate src.ip file.Then you can do whatever you want.

On your first question JD-GUI is just a viewer you need to use dex2jar to retrieve the JAR file; decompile and save the classes you need to change; import JAR and JAVA files in your Android Studio; modify; recompile and repackaged.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM