Search code examples
ubuntuintellij-ideajavadocjava-17

Ubuntu Java 17 openjdk java docs don't appear in IntelliJ


I can't get openjdk 17 JavaDocs to work in IntelliJ 2022.3.2 CE on Ubuntu 20.04. As soon as I switch to Internal IntelliJ Amazon Corretto 19 SDK - I see javadoc but for openjdk sdk 17 I see decompiled code instead.

:~$ sudo apt install openjdk-17-
openjdk-17-dbg           openjdk-17-jdk           openjdk-17-jre-headless
openjdk-17-demo          openjdk-17-jdk-headless  openjdk-17-jre-zero
openjdk-17-doc           openjdk-17-jre           openjdk-17-source
:~$ sudo apt install openjdk-17-jdk
openjdk-17-jdk           openjdk-17-jdk-headless  

:~$ sudo apt install openjdk-17-jdk
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libxt-dev openjdk-17-jdk-headless openjdk-17-jre openjdk-17-jre-headless
Suggested packages:
  libxt-doc openjdk-17-demo openjdk-17-source visualvm fonts-ipafont-gothic
  fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei
The following NEW packages will be installed
  libxt-dev openjdk-17-jdk openjdk-17-jdk-headless openjdk-17-jre
  openjdk-17-jre-headless
0 to upgrade, 5 to newly install, 0 to remove and 91 not to upgrade.
Need to get 243 MB/287 MB of archives.
After this operation, 447 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 openjdk-17-jdk-headless amd64 17.0.5+8-2ubuntu1~20.04 [243 MB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 openjdk-17-jdk amd64 17.0.5+8-2ubuntu1~20.04 [10.5 kB]
Fetched 65.3 MB in 3s (21.5 MB/s)          
:~$ java -version
openjdk version "17.0.5" 2022-10-18
OpenJDK Runtime Environment (build 17.0.5+8-Ubuntu-2ubuntu120.04)
OpenJDK 64-Bit Server VM (build 17.0.5+8-Ubuntu-2ubuntu120.04, mixed mode, sharing)

:/usr/lib/jvm$ ls
default-java  java-1.11.0-openjdk-amd64  java-1.17.0-openjdk-amd64  java-11-openjdk-amd64  java-17-openjdk-amd64  openjdk-17
:/usr/lib/jvm/java-17-openjdk-amd64/docs$ ls 
api  changelog.Debian.gz  copyright  index.html  JAVA_HOME  legal  README.alternatives  README.Debian  resources  specs  test-amd64

Now Intellij seemingly points to this path on sdk which is correct:

enter image description here

But only I see:

enter image description here

Switch to corretto and everything works as expected.

Notable difference is that Corretto seems to have "Sourcepath" section populated in IntelliJ screenshot I have provided.


Solution

  • Figured this out, thanks Ubuntu devs I guess for shipping stripped version of JDK by default, I keep telling that for workstation distros this fashion of headless just results in wasted time - include completely or don't include at all, it would be faster for myself to install adoptopenjdk correctly myself from scratch. Docker images or anything that goes on a server or in a cloud can be stripped - fine but not on Linux user distros, PLEASE

    Solution:

    Uninstall whatever openjdk-17 was installed including JRE and use the one with sources:

    :~$ sudo apt install openjdk-17-source

    instead of:

    :~$ sudo apt install openjdk-17-jdk

    as I've done at the question sample originally.

    After this IntelliJ populates "Sourcepath" similarly as it does for internal Corretto and JavaDoc works.