反编译Java项目并编译 [英] Decompile a Java project and compile

查看:1030
本文介绍了反编译Java项目并编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试反编译一个java项目(.jar)文件,我可以从中获取.java文件。现在我该如何编译回来?我能够将.java文件添加到Netbeans中,就像单个文件一样。但是如何将它添加为项目添加编译呢?该项目是一个JavaFX项目。所以请帮助我。

I am trying to decompile a java project(.jar) file and I am able to get .java files from it. Now how can I compile it back? I am able to add the .java files to Netbeans just as a single file.But how can I add it as a project add compile it? The project is a JavaFX project. So please help me on this.

推荐答案

有很多方法可以实现这一目标,但我认为你不会将jar中的项目导入开箱即用(在这种情况下,这是一种非常有用的)。

There are many ways to achieve this, but I don't think you will be able to import the project inside the jar just out of the box ( in this case, out-of-the-jar ) like that.

我们可以使用最基本的技术(我承认有点脏)但是它有效。

We can use the most basic technique ( a bit dirty I admit ) but it works.


  1. 在目录中提取jar的内容并像之前那样对其进行反编译

  2. 接下来,在netbeans中创建一个空项目(没有src目录或任何内容)

  3. 将反编译项目的内容复制到此netbeans文件夹中。您现在应该看到一些文件的骨架结构。 注意 poject是inisde netbeans但它还不是一个java项目。

  4. 编辑netbeans项目的类路径并添加java库以使其成为Java netbeans项目。

  1. Extract the contents of the jar in a directory and decompile it like you done it before
  2. Next, make an empty project inside netbeans ( with no src directory or anything )
  3. Copy the contents of your decompiled project into this netbeans folder. You should now see a skeleton structure of some files. Note The poject is inisde netbeans but it is not a java project yet.
  4. Edit the classpath of the netbeans project and add java library to make it into a Java netbeans project.

我有时使用的另一种技术是我制作IDE所需的所有项目文件(在我的案例中是Eclipse) )手动然后告诉eclipse导入项目。当eclipse找到所有必需的文件(.project,.classpath和all)时,它会很好地导入IDE中

The other technique that I use sometimes is that I make all the project files required by the IDE (Eclipse in my case) manually and then tell eclipse to import the project. When eclipse finds all the required files ( .project, .classpath and all ), it imports into the IDE just fine

这篇关于反编译Java项目并编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆