Skip to content

Allow opening Javadoc in browser #1247

Open

Description

@anthonyvdotbe

I often want to view the Javadoc in the browser for easier reading, or to read package/module documentation (which afaik isn't easily viewable somehow inside VS Code).

Environment
  • Operating System: Windows 10
  • JDK version: 13.0.1
  • Visual Studio Code version: 1.41.1
  • Java extension version: 0.55.1
Steps To Reproduce

option 1:

  1. hover over an element

option 2:

  1. trigger autocompletion for an elemention
Current Result

option 1:
image

option 2:
image

Expected Result

I'd like for the pop-up dialogs to have an icon which opens the Javadoc of the element in the default browser. I'd already be very happy if this would work for just JDK classes, but ideally this would also work for Maven dependencies.

Activity

  1. akaroml commented on Feb 17, 2020

    @akaroml
    Contributor

    I agree that a separate window is more efficient to read the docs.

    The doc is generated by JDT and rendered by VS Code. For this to happen, we have the following options:

    1. VS Code to provide the mechanism to render docs in a separate editor view (like the markdown preview)
    2. Java LS to start a webserver and provide a link in the returned result, for users to open in browser...

    I don't' see a straight answer here.

  2. anthonyvdotbe commented on Feb 19, 2020

    @anthonyvdotbe
    Author

    In NetBeans, option 2 is used. Using the same method as above, I get:

    image

    where clicking the red-circled icon opens the method's documentation in the browser.

    For JDK classes, as in this example, it uses the official Javadoc, e.g. in this case https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/util/Objects.html#requireNonNull%28T%29

    For Maven dependencies, it uses a simple webserver that relies on the Javadoc JARs from the local Maven repository, e.g. for a Guava method: http://127.0.0.1:8082/resource/jar%3Afile%3A/D%3A/Maven%2520repository/com/google/guava/guava/28.2-jre/guava-28.2-jre-javadoc.jar%21/com/google/common/base/Preconditions.html#checkNotNull%28T%29

    So I would like something similar in VS Code. And neither VS Code nor Java LS would need to render anything themselves: the JDK Javadocs are available online, and the Javadocs for Maven artifacts are (almost) always provided alongside the binary JARs.

  3. manojbaishya commented on May 31, 2021

    @manojbaishya

    There is an extension now, Docs View, that displays in a separate panel.

    image

  4. oliviercailloux commented on Oct 16, 2023

    @oliviercailloux

    Note, as a workaround, that one can apparently open the javadoc from Firefox using the JAR file. For example, browsing to
    jar:file:///home/myusername/.m2/repository/com/google/guava/guava/32.0.1-jre/guava-32.0.1-jre-javadoc.jar!/index.html opens the doc, for me.

    If there is general browser support for the jar:file protocol, this provides a solution for VSCode with no need of web server. Otherwise, perhaps at least it can provide this option if it detects that Firefox is installed?

  5. Marcono1234 commented on Jul 30, 2026

    @Marcono1234

    Side note: Recent VS Code versions also have an integrated browser (can open it with F1 > Browser: Open Integrated Browser) which seems to work ok for viewing Javadoc (at least the standard JDK 25 one). Maybe that could be an option as well?

    Unfortunately it seems there is no first-class API for extensions yet to open links in the integrated browser, see microsoft/vscode#311064.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions