Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javadoc not showing on hover in VSCode

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
like image 923
Arthur Avatar asked Nov 03 '25 12:11

Arthur


1 Answers

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

like image 171
Henry Fung Avatar answered Nov 05 '25 03:11

Henry Fung



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!