6

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!

3
  • How about running your code in external Terminal? use javac Helloworld.java to generate .class file. Then run java Helloworld to show result. if there's no error shown, try to clean java workspace and reinstall Java Extension Pack in VS Code. Commented Mar 17, 2021 at 7:54
  • @MollyWang it says in the terminal could not find or load main Class Helloworld, what does this mean? Commented Mar 19, 2021 at 3:45
  • Can you show the error screenshots? both the folder structure in vscode and the error in external terminal. please provide as much information about your question as possible. Commented Mar 19, 2021 at 3:51

5 Answers 5

7
  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

Sign up to request clarification or add additional context in comments.

Comments

0

In VSCode:

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

Comments

0

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

<Ctrl-P> Developer: Reload Window

or simply,

<Ctrl-R>

Comments

0

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

Comments

0

If you are facing this error around the time of this post March 2023, there is a bug in vscode-java-dependency extension. You can either check if you have the latest version or try to install this pre-release, it fixed it for me:

https://github.com/microsoft/vscode-java-dependency/issues/720

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.