Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show Javadoc on hover in VS Code in Java Project?

In my Mac OS 10.14 I have VS Code 1.47.3 and yesterday installed Java Extension Pack 0.9.1. I am able to run Java project (Maven) but I do not see any javadoc on hover feature. For example when mouse pointer is hovering on ds.show() (line 29) in screenshot, I expect to see hover pane showing docs on show method like it shows in same eclipse project. I have JDK8 and OpenJDK14 installed on my system.

Here is the screenshot:

enter image description here

Below is not important: Also how to disable annoying logs in Terminal window when I am editing file? These logs look like:

3a6e249d Publish Diagnostics [Done]
6dcf0221 Building [Done]
ebb16695 Building [Done]
0e4416a3 Validate documents [Done]

As can be seen in screenshot.

like image 207
ace Avatar asked Aug 07 '20 05:08

ace


People also ask

How do you add javadoc to VS code?

Javadoc Tools for Visual Studio Code Can also be triggered from the right-click context menu within a file. Javadoc Tools: Generate Javadoc Comments for Workspace - Generates Javadoc for all classes within the workspace. The files will be opened in the editor and the javadoc comments will be added.

How do I display javadoc?

View Javadocs in the editorHover the mouse over the necessary symbol in the editor. Place the caret at the symbol and press Ctrl+Q (View | Quick Documentation). Press Ctrl+Q again to open this documentation in the Documentation tool window.

How do I load a javadoc?

Step 1 − Open eclipse, select the option Project →Generate Javadoc. Step 2 − Select the javadoc.exe file from the bin folder of java installation directory, select the destination folder for the generated java doc and select Next. finish button.

How do you view documents in VS code?

Definition Preview Hover from the keyboard There is a new command Show Definition Preview Hover for better accessibility of the definition preview hover widget, which can be triggered by hovering a symbol with the mouse and pressing a modifier key dependent on the platform and configuration.


1 Answers

If you are still stuck, I found a way, just try enabling 'Intellisense' in your red hat java extension. This may work for you. And for those logs, looks like your are running your application in debug mode. Your can't disable them if that's the case.

EDIT (The actual solution):

Javafx java docs in vs code
To achieve the above results, follow bellow steps.

  1. Go to User/Workspace settings.
  2. Hit ctrl f and type java.project.referencedLibraries.
  3. Click edit in settings.json.
  4. Paste the following setting.
"java.project.referencedLibraries": {
    "include": [
        "lib/**/*.jar",
        "%PATH_TO_FX%/lib/*.jar"
    ],
    "sources": {
        "%PATH_TO_FX%/lib/javafx.base.jar": "%PATH_TO_FX%/src.zip",
        "%PATH_TO_FX%/lib/javafx.controls.jar": "%PATH_TO_FX%/src.zip",
        "%PATH_TO_FX%/lib/javafx.fxml.jar": "%PATH_TO_FX%/src.zip",
        "%PATH_TO_FX%/lib/javafx.graphics.jar": "%PATH_TO_FX%/src.zip",
        "%PATH_TO_FX%/lib/javafx.media.jar": "%PATH_TO_FX%/src.zip",
        "%PATH_TO_FX%/lib/javafx.swing.jar": "%PATH_TO_FX%/src.zip",
        "%PATH_TO_FX%/lib/javafx.web.jar": "%PATH_TO_FX%/src.zip",
        "%PATH_TO_FX%/lib/javafx.swt.jar": "%PATH_TO_FX%/src.zip"
    }
}

Here %PATH_TO_Fx% is the path to the javafx folder or javafx env variable. Be sure if you are linux/mac user type it like $PATH_TO_FX. To set enviorment vairable for javafx refer the getting started section of openjfx.org

like image 198
Wild Martian Avatar answered Oct 04 '22 01:10

Wild Martian