DEV Community

Cover image for Two ways to integrate Javadoc into IntelliJ IDEA
scottshipp
scottshipp

Posted on • Updated on

Two ways to integrate Javadoc into IntelliJ IDEA

Do you Google for Javadoc? Isn't it annoying? Picture this: you're in a flow state, with a full stack on your mind, and a good couple dozen business concepts thrown in, and you just want to double-check the behavior of a given library method. Do you really want to stop what you're doing, open a browser, search for the library documentation, make sure you are looking at the right version, and then navigate to the class and method in question?

You don't have to!

Here are two fast and easy ways to add Javadoc to IntelliJ so you can see it using the "Quick Documentation" feature: simply hover your mouse on any piece of code or use the Quick Documentation shortcut key, Ctrl+Q for Linux or Windows and F1 on macOS!

Now, on to the first way.

Using Maven

On Maven projects, run the dependency:resolve phase with classifier=javadoc and IntelliJ will automatically acquire documentation superpowers.

There are two ways to run this. First, you can run the following Maven command from the terminal inside the root directory for the project:

$ mvn dependency:resolve -Dclassifier=javadoc
Enter fullscreen mode Exit fullscreen mode

You can also run that from the "Execute Maven goal" window, which appears when you open the Maven tool window (View > Tool windows > Maven) and press the "M" icon.

The Execute Maven Goal window in IntelliJ

If you want, you can even tell Maven to always download Javadoc when available. Navigate to Preferences > Build, Execution, Deployment > Build Tools > Maven > Importing and check the Automatically download documentation checkbox.

With a URL or Jar file

Do you have a URL to some Javadoc on the web? Then open Project Structure, navigate to Libraries, and click the icon that combines a "+" and a globe.

The Libraries UI in IntelliJ

Paste the URL and save it.

If you happen to have the javadoc in a jar file instead, you can use the normal "+" icon you see in this same Project Structure > Libraries window.

What it looks like

With any of those settings in place, you can simply hover your mouse on any piece of code and see the resulting Javadoc.

Quick Documentation view in IntelliJ

Conclusion

With Javadoc just a mouse-hover away, you can remain focused on the task at hand rather than disrupting your flow and going on a wild goose chase.

Photo by Miriam Espacio from Pexels

Top comments (0)