将.java文件作为IntelliJ中.jar的源附加? [英] Attach .java file as source for .jar in IntelliJ?

查看:139
本文介绍了将.java文件作为IntelliJ中.jar的源附加?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试逐步完成IntelliJ中的项目。作为其中的一部分,我需要强行进入一个罐子里。这导致IntelliJ为我反编译jar并向我显示将要运行的代码,但它不会让我实际执行反编译代码 - 如果我单击任何步骤按钮,它只是一直步骤直到控制退出反编译的jar。

I'm trying to step through a project in IntelliJ. As part of that, I need to force step into a jar. That causes IntelliJ to decompile the jar for me and show me the code that will be run, but it doesn't let me actually step through that decompiled code - if I click any of the step buttons, it just steps all the way until control exits the decompiled jar.

环顾四周,它看起来像是一个可能的解决方案,允许我实际执行代码是附加源代码。我有源代码,作为.java文件,用于我想要介入的特定类,但IntelliJ似乎不允许我添加.java文件作为源。

Looking around, it looks like a possible solution to allow me to actually step through the code is to attach the source code. I have the source code, as a .java file, for the specific class that I'd like to step into, but IntelliJ doesn't seem to be allowing me to add .java files as source.

那么如何在IntelliJ中将.java文件附加为.jar的源代码?或者,如果这不是正确的方法,我怎样才能在反编译类中使用步进器?

So how can I get a .java file attached as source for a .jar in IntelliJ? Or, if that's not the right approach, how can I go about using the stepper within a decompiled class?

推荐答案

你需要将您的Java文件放入正确的目录结构中。例如,假设您在myjar.jar中有一个com.mypackage.MyClass类。然后你需要创建以下结构:

You need to put your Java file into a correct directory structure. For example, suppose you have a class com.mypackage.MyClass in myjar.jar. Then you need to create the following structure:

myjar
  com
    mypackage
      MyClass.java

一旦这样做,请附上myjar目录作为.jar文件的来源,并且在调试时你会看到正确的源代码。

Once you do that, attach the "myjar" directory as a source for your .jar file, and you'll see the correct source code while debugging.

这篇关于将.java文件作为IntelliJ中.jar的源附加?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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