Java "'java.execute.workspaceCommand' failed" in VSCode

Viewed 7115

I recently wanted to try Java, so i started out with Hello World! I installed OpenJDK 11 for VSCode and ran the program, but it produced the following error: Running the contributed command: 'java.execute.workspaceCommand' failed.

I looked at the Java runtime configuration and it detected the JDK, but it showed that error!

4 Answers
  1. Go to extensions tab
  2. Search for Java extension package
  3. Click on disable. If it gets disabled, well and good otherwise a pop-up may appear at the bottom, in the bottom of pop-up, click on disable for all windows or something similar text.
  4. Enable the Java extension package again.

In my case, it worked after step 4, let me know about yours

In VSCode:

  1. Go to "Extensions"
  2. Type "Java Extension Pack"
  3. Uninstall
  4. Install

I had this error, and it disappeared after reloading the window:

<Ctrl-P> Developer: Reload Window

or simply,

<Ctrl-R>

I was running into this problem when something with my maven repository settings was incorrect. When I placed the right settings.xml file in the .m2 directory, I was able to launch the program from vscode.

I could also be related to this issue: https://github.com/redhat-developer/vscode-java/issues/1929

Related