Attach .java file as source for .jar in IntelliJ?

I am trying to execute a project in IntelliJ. As part of this, I need to take a step to the bank. This forces IntelliJ to decompile the jar for me and show me the code that will be run, but it doesn’t allow me to actually go through this decompiled code - if I click on any of the step buttons, it will simply act until it leaves a decompiled jar.

Looking back, this seems like a possible solution, allowing me to actually go through the code to attach the source code. I have the source code as a .java file for a specific class that I would like to enter, but IntelliJ does not seem to allow me to add .java files as a source.

So, how can I get the .java file as the source for the .jar in IntelliJ? Or, if this is not the right approach, how can I use a pedometer in a decompiled class?

+1
source share
1 answer

You need to put your Java file in the 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

Once you do this, attach the "myjar" directory as the source for your .jar file, and during debugging you will see the correct source code.

+1
source

Source: https://habr.com/ru/post/1609999/


All Articles