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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27329537/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 11:38:05  来源:igfitidea点击:

jar edit and re-compile in simple way

java

提问by Syed Sajid

I have a jar file called ScreenCapture.jar

我有一个名为 ScreenCapture.jar 的 jar 文件

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

我使用http://jd.benow.ca/里面有什么。我什至下载了 jd-gui

This is what it shows me

这就是它向我展示的

screenCapture

截屏

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

我可以看到 ScreenCapture.class 文件。我想在这里编辑 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 一无所知,而且我的机器上没有安装任何特殊的应用程序/软件

回答by Nazgul

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.
  1. 创建一个eclipse项目
  2. 将 jar 作为依赖项添加到该项目
  3. 在包 screencapture 中创建一个名为 ScreenCapture.java 的新类。
  4. 从您的 JD 复制整个源代码也查看您在此处附加的屏幕截图。
  5. 更改您想要的代码。
  6. 构建项目
  7. 检查 eclipse 项目的 bin 文件夹。这将具有新编译的 .class 文件。
  8. 在 winrar 中打开 jar 并将 .class 文件从 bin 文件夹复制到你的 jar 中。
  9. 你就完成了。

回答by Nisanth Kumar

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 文件。然后你可以为所欲为。

回答by Abdallah Abdillah

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.

关于您的第一个问题,JD-GUI 只是一个查看器,您需要使用 dex2jar 来检索 JAR 文件;反编译并保存需要更改的类;在你的 Android Studio 中导入 JAR 和 JAVA 文件;调整; 重新编译并重新打包。