java - Getting Error occurred during initialization of VM in vs code - Stack Overflow

admin2025-04-18  6

I have installed Visual Studio Code for java web application development. In VS Code i have installed extension for java. After installation of extension for java my Configure Java Runtime screen is coming blank. I went to settings.json file and set the below thing.

{
    "workbench.colorTheme": "Default Dark+",
    "java.jdt.ls.java.home": "C:\\Program Files (x86)\\jdk-8",
   
}

Whenever i am trying to create maven-archtype-webapp i am getting below error in terminal.

  • Executing task: "mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate -DarchetypeArtifactId="maven-archetype-webapp" -DarchetypeGroupId="org.apache.maven.archetypes" -DarchetypeVersion="1.4" -DgroupId="com.example" -DartifactId="demo"" Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object
  • The terminal process "cmd.exe /c "mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate -DarchetypeArtifactId="maven-archetype-webapp" -DarchetypeGroupId="org.apache.maven.archetypes" -DarchetypeVersion="1.4" -DgroupId="com.example" -DartifactId="demo""" terminated with exit code: 1.
  • Terminal will be reused by tasks, press any key to close it.*

Can someone please help me on this ?

I have installed Visual Studio Code for java web application development. In VS Code i have installed extension for java. After installation of extension for java my Configure Java Runtime screen is coming blank. I went to settings.json file and set the below thing.

{
    "workbench.colorTheme": "Default Dark+",
    "java.jdt.ls.java.home": "C:\\Program Files (x86)\\jdk-8",
   
}

Whenever i am trying to create maven-archtype-webapp i am getting below error in terminal.

  • Executing task: "mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate -DarchetypeArtifactId="maven-archetype-webapp" -DarchetypeGroupId="org.apache.maven.archetypes" -DarchetypeVersion="1.4" -DgroupId="com.example" -DartifactId="demo"" Error occurred during initialization of VM java/lang/NoClassDefFoundError: java/lang/Object
  • The terminal process "cmd.exe /c "mvn org.apache.maven.plugins:maven-archetype-plugin:3.1.2:generate -DarchetypeArtifactId="maven-archetype-webapp" -DarchetypeGroupId="org.apache.maven.archetypes" -DarchetypeVersion="1.4" -DgroupId="com.example" -DartifactId="demo""" terminated with exit code: 1.
  • Terminal will be reused by tasks, press any key to close it.*

Can someone please help me on this ?

Share Improve this question edited Jan 30 at 20:26 rioV8 29.1k4 gold badges42 silver badges61 bronze badges asked Jan 30 at 9:20 Ajinkya kadamAjinkya kadam 6041 gold badge7 silver badges18 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

This is probably caused by the version of the JDK you are trying to configure is not compatible with the current requirements for the Java extension.

See https://github.com/redhat-developer/vscode-java/wiki/JDK-Requirements#about-the-java-21-requirement for details:

As of January 9, 2025, Java 21 will be required for running all new releases (eg. >= 1.39.0 and existing pre-relases) of vscode-java.

If your project requires a different JDK version (like JDK 8) you can configure different versions for project level JDKs using the java.configuration.runtimes.

Example:

"java.configuration.runtimes": [
  {
    "name": "JavaSE-1.8",
    "path": "/path/to/jdk-8",
  },
  {
    "name": "JavaSE-11",
    "path": "/path/to/jdk-11",
  },
  {
    "name": "JavaSE-17",
    "path": "/path/to/jdk-17",
    "default": true
  },
]
转载请注明原文地址:http://anycun.com/QandA/1744929682a89632.html