jDoc

Finding the right documentation

Let’s take a look at what “looking it up” usually means for me. I search for the class and the method, and I add the Java version I’m using. Something like this:

java 17 List getFirst

I open a result and check which Java version it covers. On the Java 17 page, getFirst() isn’t in the method summary. Did I spell it wrong? Am I thinking of a different class? Which version introduced it? After a while, I find out the method was only added to List in Java 21. But the Java 17 page doesn’t directly explain that absence.

The documentation tells me what is available in that release. Answering why a method is missing can take more searching. And including a version in my search query is only a hint to the search engine, not a filter.

I spend most of my day in a terminal. My builds, tests, Git and logs are all there. When I have a question, my instinct is to type a command and get an answer in the same window. Reaching for the mouse, switching to a browser, searching and scrolling isn’t hard. It’s just enough of an interruption to break my train of thought. Those interruptions add up.

I wanted a tool that fits the way I already work: type a command, read the answer and carry on.

Why IntelliJ wasn’t quite enough

IntelliJ shows Javadoc right in the editor, and most of the time it’s great. But it didn’t quite fit how I wanted to explore documentation.

More than once, I moved my mouse to click a link inside a documentation popup, and it disappeared. IntelliJ lets you pin documentation or open it in a tool window.

Navigating to a declaration is a different experience again. Without attached sources, I can end up looking at decompiled code, which cannot recover the original Javadoc comments from a compiled class. With sources attached, I’m reading a source file, with implementation code and private helpers alongside the public API. Neither is the focused overview I was looking for.

What I wanted was a quick way to survey a class: see what it offers, narrow it down and read only what I need.

Documentation in the terminal

jDoc is a terminal browser for Java API documentation. It covers Java 17, 21 and 25 (as of now), and reads the same official Javadoc you’d find in the browser, just presented differently. The simplest way to use it is to give it a class name:

jDoc String

This opens an interactive list of methods on String, each with a short description. Start typing rep, and the list narrows to repeat, replace, replaceAll and replaceFirst. Press Enter to read the full documentation, including any examples already present in the official Javadoc. Links are preserved too. Go back, and you’re on the list again.

If you already know what you want, you can skip the list entirely:

jDoc String -repeat

jDoc can also inspect version declarations in your project’s pom.xml or build.gradle to choose a documentation release. It reads the files without running your build. This is static detection: it should not be treated as a complete evaluation of inherited or dynamically configured build settings. You can explicitly select a release with --docVersion <release>.

For example, in a project whose pom.xml explicitly sets maven.compiler.release to 17:

jDoc List -getFirst

With the relevant releases cached, the output looks like this:

Multiple classes named List:
  1. java.awt.List
  2. java.util.List
Choose a number (Enter to cancel): 2
jDoc: No matching documented member on java.util.List in Java 17.
Available in other cached releases:
  Java 25: getFirst() documented on java.util.List (declaring type unverified; cache its class page for details)
Cannot determine availability for Java 21 from the local cache. Select a release to cache its API index/page.

That answers the question the Java 17 method list couldn’t answer on its own: the method isn’t available in this release, and it was added in Java 21. The cross-release lookup uses cached documentation, so what it can report depends on which releases are available locally.

What else does it do?

A few other things it does today:

Pages are downloaded when first needed and cached locally. Previously fetched pages can then be read offline; uncached pages still need a connection.

Something I learned along the way

At one point, I ran jDoc HashMap -stream and got nothing back. My first thought was that jDoc was broken. It wasn’t. HashMap doesn’t have a stream() method. stream() is declared on Collection, and Map isn’t a Collection. You stream a map’s entries, keys or values through entrySet(), keySet() or values().

I had used map.entrySet().stream() hundreds of times without ever thinking about why the entrySet() was needed. The tool I built to answer my questions ended up answering one I hadn’t thought to ask.

Where I want to take it

jDoc currently displays the official documentation, next, I’d like to add support for popular libraries such as Spring, Jackson and Guava, along with a layer of short, practical usage examples: a minimal snippet, its expected output and, where useful, a common pitfall.

The goal is to make it easier to go from understanding what a method does to using it effectively, without jumping between two or three websites.

jDoc is open source and available on GitHub. If you live in the terminal like I do, give it a try. And if something doesn’t work the way you expect, open an issue. I’d love to hear about it.

This post was written by me, with an AI assistant helping draft and edit it.