Visual Studio Code not recognizing java project

Viewed 9281

VS Code is not recognizing my java project. The project is template code for a minecraft mod found here. Ive installed the plugins

  • "Debugger for Java"
  • "Java Extension Pack"
  • "Language Support for Java by Redhat"
  • "Java Test Runner"
  • "Project Manager for Java"

I also get an error related to gradle.

Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.0.2-bin.zip'.
java.io.StreamCorruptedException: invalid type code: 00
invalid type code: 00

And here is my settings.json file

{
    "files.exclude": {
        "**/.classpath": true,
        "**/.project": true,
        "**/.settings": true,
        "**/.factorypath": true
    },
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "java.configuration.updateBuildConfiguration": "interactive",
    "java.home": "/usr/lib/jvm/java-16-openjdk-amd64",
    "java.configuration.runtimes": [
        {
          "name": "JavaSE-1.8",
          "path": "/usr/lib/jvm/java-8-openjdk-amd64",
          "default": true
        },
    ]
}

I have no code completion for my Java files. Before it was working and in the lower right corner of visual studio it displayed the java version i was using but now it just says Java. I'm assuming its because there is a problem with gradle and thus cannot figure out my java version. Thank you for your time.

Update: This seems to work and give me auto completion but i stil get a gradle related error mention above.

{
    "files.exclude": {
        "**/.classpath": true,
        "**/.project": true,
        "**/.settings": true,
        "**/.factorypath": true
    },
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "java.configuration.updateBuildConfiguration": "interactive",
    "java.home": "/usr/lib/jvm/java-16-openjdk-amd64",
    "java.configuration.runtimes": [
        {
          "name": "JavaSE-1.8",
          "path": "/usr/lib/jvm/java-8-openjdk-amd64",
          "default": true
        },
        {
            "name": "JavaSE-16",
            "path": "/usr/lib/jvm/java-16-openjdk-amd64",
        },
    ]
}
1 Answers

For anyone who is stuck with the same problem as me make sure your settings.json file looks similar to mine including both java 1.8 run config and the java 11+ run config same as the one specified as the home path. That should fix the java language level. The gradle error you can ignore but you must use gradle runClient instead of the run configuration that vscode provides. Happy modding :D

Related