Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 535
Mohamad Ali Honarpisheh Avatar asked May 28 '12 07:05

Mohamad Ali Honarpisheh


People also ask

How do I know where a class is used in IntelliJ?

From the main menu, select Edit | Find Usages | Show Usages In Code Ctrl+Alt+F7 . The usages window shows the current scope and total count of usages. If you want to quickly switch to the default scope, press Ctrl+Alt+F7 .

Where are class files stored in IntelliJ?

class files. Inside the output directory, IntelliJ IDEA also creates subdirectories for each of your modules. The default paths for subdirectories are as follows: Sources: <ProjectFolder>/out/production/<ModuleName>

How do I go back to previous class in IntelliJ?

Use ⌘[ (macOS), Ctrl+Alt+Left Arrow (Windows/Linux) to navigate backwards and ⌘] (macOS), Ctrl+Alt+Right Arrow (Windows/Linux), to navigate forwards.


1 Answers

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 maven, IntelliJ will automatically download and attach available source to all libraries, no manual work needed.

like image 104
Tomasz Nurkiewicz Avatar answered Oct 20 '22 01:10

Tomasz Nurkiewicz