Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jar edit and re-compile in simple way

Tags:

java

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

screenCapture

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

like image 591
Syed Sajid Avatar asked Dec 06 '14 07:12

Syed Sajid


2 Answers

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.
like image 114
Nazgul Avatar answered Sep 20 '22 23:09

Nazgul


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

like image 38
Nisanth Kumar Avatar answered Sep 19 '22 23:09

Nisanth Kumar