Javadoc not showing on hover in VSCode
Asked Answered
I

4

4

I'm currently working on a java project using VSCode and when I hover an object, type or method name, documentation isn't showing anymore. I do not know why or what I did to change that.

In the following picture, I am hovering the first occurence of ByteBuyUtils, and as we can see, nothing is shown.

first hovering example

Here is a picture found on google pictures showing what I want to get when hovering something :

example of what I want when hovering code

I'm using 1.65.1 version of VSCode, on Ubuntu 21.10. I am using openjdk version "18-ea" 2022-03-15.

The following extensions are installed on my VSCode :

  • Language Support for Java(TM) by Red Hat
  • Debugger for Java
  • Test Runner for Java
Intelligible answered 10/3, 2022 at 15:31 Comment(5)
this is a editor problem!!Spaulding
Yes, probably, but this doesn't change the fact that I don't know how to fix itIntelligible
just search for a java extension in vscode extensions, and install itSpaulding
Sometimes Test Runner for Java will have some conflicts with Red Hat extension, can you uninstall the extension "Test Runner for Java" and restart VS Code to see if it works?Drank
Thanks for your response, the problem does not come from any extension but from my project itself. I am currently working on it.Intelligible
K
7

You may try a couple of things.

maven

If you are using maven, you need to explicitly download javadoc and source of the packages in your project.

  • To download source code: mvn dependency:sources
  • To download javadoc: mvn dependency:resolve -Dclassifier=javadoc

java home property

In vscode, you need to set java home property.

  • Ctrl+Shift+p to open command palette
  • search for user settings json
  • the settings.json should be opened
  • add a field java.jdt.ls.java.home and set the value to the root folder of your openjdk package.

For me, it's /usr/lib/jvm/java-17-openjdk-amd64. So I add

"java.jdt.ls.java.home": "/usr/lib/jvm/java-17-openjdk-amd64"

to the settings.json.

To find yours, try

$ which java
/usr/bin/java
$ ls -l /usr/bin/java
......  /usr/bin/java -> /etc/alternatives/java
$ ls -l /etc/alternatives/java
......  /etc/alternatives/java -> /usr/lib/jvm/java-17-openjdk-amd64/bin/java

Trace all the way down with ls -l. The last path before the /bin/java part is your JAVA_HOME.

install openjdk javadoc

You can download the doc of your openjdk version via. apt on Ubuntu.

$ sudo apt update
$ apt list | grep openjdk-17-

You should see openjdk-17-doc and openjdk-17-source available. Change 17 to your version of choice (18 for example). Then

$ sudo apt install openjdk-17-doc openjdk-17-source

Finally

Restart vscode

Kiushu answered 9/11, 2022 at 3:30 Comment(0)
J
2

I was having this problem, and tried everyone's suggestions of adding this or that edit to the settings and none of them had any effect. It turns out I needed to install the openjdk source package. For java 17 on Ubuntu, you'd run this in a terminal:

sudo apt install openjdk-17-source
Jamaaljamaica answered 2/11, 2023 at 21:19 Comment(0)
X
0

Maybe this is the extension you need:Visual Studio IntelliCode You can also read this article to see some of the extensions that Java needs: https://code.visualstudio.com/docs/java/java-tutorial

Xhosa answered 11/3, 2022 at 3:1 Comment(3)
I installed the extension Visual Studio IntelliCode but it didn't change anything. I will try searching in the java-tutorial from VSCode doc. Thanks !Intelligible
@Intelligible Have you solved the problem now? If not, I think you can provide more information for me to understand the specific situationXhosa
Thanks for your response, I found the source of the problem and it has nothing to do with VSCode, I am currently working on finding a solution.Intelligible
I
0

It stands to reason that the extension you downloaded has this function to show that... why don't you install an intelligent prompt extension such as this oneto have a try? Or please check it out if you have turned off the setting:editor.hover.enabled(in the lower right corner and search for hover)?

Injection answered 11/3, 2022 at 3:28 Comment(2)
This setting has always been turned on, also I installed Visual Studio IntelliCode but it didn't change anything. Thank you for your answer !Intelligible
I'm sorry to hear that. To remedy the situation, I'm getting this again:link, hope this helps.Injection

© 2022 - 2024 — McMap. All rights reserved.