Search code examples
javaintellij-idea

View sources of used Java classes in IntelliJ Idea


In visual studio development environment when you use a library if you have the related pdb you can dig into their sources during debug. I wonder is there any way to have this feature when you are developing under Java with IntelliJ Idea IDE? I want to see what hibernate do.


Solution

  • Of course, quoting the documentation:

    Libraries may optionally include the source code for the library classes as well as corresponding API documentation. [...] However, it adds the ability to use inline documentation extracted from the source code, and also to view the API documentation right from the IDE.

    The documentation doesn't mention you can then debug external libraries, which is obviously also possible.

    In order to add sources choose:

    • File | Project Structure
    • Click Libraries tab
    • Pick library and click + icon
    • Find a JAR file containing sources.

    If you are using build tool like , IntelliJ will automatically download and attach available source to all libraries, no manual work needed.