Sts4: can't recognize JAVA_HOME while its value was set

Created on 21 Aug 2019  ·  6Comments  ·  Source: spring-projects/sts4

I have this error message:

JAVA_HOME or PATH environment variable seems to point to a JRE. A JDK is required, hence Boot Hints are unavailable.

notice that I have set these settings in vs code settings.json

{
...
    "java.home": "/usr/lib/jvm/java-12-openjdk",
    "spring-boot.ls.java.home": "/usr/lib/jvm/java-12-openjdk",
...
}
[MohamedAmin@samet ~]$ printenv JAVA_HOME
/usr/lib/jvm/java-12-openjdk
[MohamedAmin@samet ~]$ tree /usr/lib/jvm/java-12-openjdk -L 1
/usr/lib/jvm/java-12-openjdk
├── bin
├── conf -> /etc/java/java-12-openjdk/java-12-openjdk-12.0.2.9-1.rolling.fc30.x86_64/conf
├── include
├── legal
├── lib
├── release
└── tapset

6 directories, 1 file

Most helpful comment

I have installed java-12-openjdk-jmods and now the problem seems to be solved. I should had done this from the first time.

Thank you @martinlippert and @kdvolder for your feedback.

All 6 comments

The settings in your settings.json config look good to me, but it looks like the jmods directory is missing from the JDK install. Therefore the vs code extension assumes that this module is not around and tries to inform you about that. Do the live hover work nevertheless? And where are the jmod files of your JDK install? Somewhere else?

I made a quick search for jmod location.

[MohamedAmin@samet ~]$ find /usr/lib/* -name *jmod* 2> /dev/null
/usr/lib/jvm/java-12-openjdk-12.0.2.9-1.rolling.fc30.x86_64/bin/jmod
[MohamedAmin@samet ~]$ readlink -f /usr/lib/jvm/java-12-openjdk
/usr/lib/jvm/java-12-openjdk-12.0.2.9-1.rolling.fc30.x86_64

The live hover does not work either.
..
ps: I use other vs code java extensions without any problem.

@Samet-MohamedAmin The find command you ran didn't seem to find any jmod. So our question still remains where are the jmods in your particular setup?

The way your jdk installation is setup is somewhat different from what is expected by STS and so it seems to be unable to find the jmods directory or its contents in your install.

For reference, I have a jdk 12 on my machine and it contains a directory called 'jmods' in which we can find a number of '.jmod' files. See:

kdvolder@dellicioso:~/Applications/jdk-12.0.1$ ls -la
total 36
drwxr-xr-x  8 kdvolder kdvolder 4096 Jun 17 16:10 .
drwxr-xr-x 21 kdvolder kdvolder 4096 Aug 13 10:19 ..
drwxr-xr-x  2 kdvolder kdvolder 4096 Jun 17 16:10 bin
drwxr-xr-x  5 kdvolder kdvolder 4096 Jun 17 16:10 conf
drwxr-xr-x  3 kdvolder kdvolder 4096 Jun 17 16:10 include
drwxr-xr-x  2 kdvolder kdvolder 4096 Jun 17 16:10 jmods
drwxr-xr-x 72 kdvolder kdvolder 4096 Jun 17 16:10 legal
drwxr-xr-x  5 kdvolder kdvolder 4096 Jun 17 16:10 lib
-rw-r--r--  1 kdvolder kdvolder 1190 Apr  1 23:50 release
kdvolder@dellicioso:~/Applications/jdk-12.0.1$ cd jmods/
kdvolder@dellicioso:~/Applications/jdk-12.0.1/jmods$ ls -la
total 79852
drwxr-xr-x 2 kdvolder kdvolder     4096 Jun 17 16:10 .
drwxr-xr-x 8 kdvolder kdvolder     4096 Jun 17 16:10 ..
-rw-r--r-- 1 kdvolder kdvolder 20828384 Apr  1 23:50 java.base.jmod
-rw-r--r-- 1 kdvolder kdvolder   119542 Apr  1 23:50 java.compiler.jmod
-rw-r--r-- 1 kdvolder kdvolder    58587 Apr  1 23:50 java.datatransfer.jmod
-rw-r--r-- 1 kdvolder kdvolder 12936441 Apr  1 23:50 java.desktop.jmod
-rw-r--r-- 1 kdvolder kdvolder    45759 Apr  1 23:50 java.instrument.jmod
-rw-r--r-- 1 kdvolder kdvolder   120093 Apr  1 23:50 java.logging.jmod
-rw-r--r-- 1 kdvolder kdvolder   890131 Apr  1 23:50 java.management.jmod
...

The live hover does not work either.

I would expect that... given that it relies on functionality from some of these jmods. So if they are not found then some features of STS 4, such as the live hovers, will not work.

I have installed java-12-openjdk-jmods and now the problem seems to be solved. I should had done this from the first time.

Thank you @martinlippert and @kdvolder for your feedback.

Thanks for letting us know and I'm glad you found a solution.

Was this page helpful?
0 / 5 - 0 ratings