skip to Main Content

After I upgraded to Java 17 (from 11), VSCode, with the java pack, will no longer recognize java projects.

enter image description here

It is a maven project, with a pom file in the root folder and then multiple projects below, like the three shown in the picture above.

It recognizes the maven part just fine, but no java projects.

I tried:

  • Setting the JAVA_HOME variable
  • Setting the "java.jdt.ls.java.home"
  • Setting a config in "java.configuration.runtimes"

What can I do to make VSCode recognize my java projects?

3

Answers


  1. Chosen as BEST ANSWER

    Setting the the maven.userSettings in settings.json did the trick!

    "java.configuration.maven.userSettings": ".mvn/settings.xml",
    

    For some reason this wasn't needed when I used Java 11, but now with Java 17 it apparently doesn't find it automatically.

    EDIT: My mistake, it can find it, I was missing the settings file in my .m2 folder, after putting it there, I don't need to set the path as above.

    So yea, either put the settings file in the home/.m2 folder or set the java.configuration.maven.userSettings


  2. Possible workarounds

    Add the following configuration to the settings.json file

        "java.jdt.ls.vmargs": "-Xlog:jni+resolve=off",
    
    Login or Signup to reply.
  3. In my case i found that the .project file was missing the following:

    <buildSpec>
            <buildCommand>
                <name>org.eclipse.jdt.core.javabuilder</name>
                <arguments>
                </arguments>
            </buildCommand>
    

    and

    <natures>
            <nature>org.eclipse.jdt.core.javanature</nature>
    

    I came to this conclusion after creating a new project in the Java Project area, and comparing the files.

    There were also entries missing in the .settings/org.eclipse.jdt.core.prefs file, but adding them didn’t fix the problem until I added the above.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search