简体   繁体   English

jar以简单的方式编辑和重新编译

[英]jar edit and re-compile in simple way

I have a jar file called ScreenCapture.jar 我有一个名为ScreenCapture.jar的jar文件

I use http://jd.benow.ca/ what is in there. 我用http://jd.benow.ca/那里有什么。 I have even downloaded jd-gui 我甚至下载了jd-gui

This is what it shows me 这就是它给我看的内容

抓屏

I can see the ScreenCapture.class file. 我可以看到ScreenCapture.class文件。 I want to edit 2 lines here 我想在这里编辑2行

      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? 所以我可以重新上传我的jar文件,一切恢复正常?

Btw, I know nothing about java, and I don't have any special application/software installed on my machine 顺便说一下,我对java一无所知,我的机器上没有安装任何特殊的应用程序/软件

follow these steps: 跟着这些步骤:

  1. Create an eclipse project 创建一个eclipse项目
  2. add the jar as a dependency to that project 添加jar作为该项目的依赖项
  3. Create a new class named ScreenCapture.java in the package screencapture. 在包screencapture中创建一个名为ScreenCapture.java的新类。
  4. copy the whole source from your JD too view the screenshot of which u attached here. 复制JD的整个源代码也可以查看你附带的截图。
  5. change the code which u want. 改变你想要的代码。
  6. build the project 建立项目
  7. check the bin folder of you eclipse project . 检查你eclipse项目的bin文件夹。 this will have the new compiled .class file. 这将有新编译的.class文件。
  8. open the jar in winrar and copy the .class file from bin folder into your jar. 在winrar中打开jar并将bin文件夹中的.class文件复制到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. 它将生成src.ip文件。然后你可以做任何你想做的事情。

On your first question JD-GUI is just a viewer you need to use dex2jar to retrieve the JAR file; 在您的第一个问题上,JD-GUI只是一个查看器,您需要使用dex2jar来检索JAR文件; decompile and save the classes you need to change; 反编译并保存您需要更改的类; import JAR and JAVA files in your Android Studio; 在Android Studio中导入JAR和JAVA文件; modify; 修改; recompile and repackaged. 重新编译并重新打包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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