Visual Studio Code – Java – Import Errors and More

We Are Going To Discuss About Visual Studio Code – Java – Import Errors and More. So lets Start this Java Article.

Visual Studio Code – Java – Import Errors and More

  1. Visual Studio Code – Java – Import Errors and More

    I ran into a similar issue. The solution was to remove everything from VS Code's workspace storage directory, which was located at $HOME/Library/Application Support/Code/User/workspaceStorage/.

  2. Visual Studio Code – Java – Import Errors and More

    I ran into a similar issue. The solution was to remove everything from VS Code's workspace storage directory, which was located at $HOME/Library/Application Support/Code/User/workspaceStorage/.

Solution 1

I ran into a similar issue. The solution was to remove everything from VS Code’s workspace storage directory, which was located at $HOME/Library/Application Support/Code/User/workspaceStorage/.

I found this solution here: https://github.com/redhat-developer/vscode-java/wiki/Troubleshooting#clean-the-workspace-directory

Update: This can now be done from within VS Code as of Language Support for Java(TM) by Red Hat Version 0.33.0. Open the command palette and type “java clean” (see official description in link).

Original Author toreyhickman Of This Content

Solution 2

As already mentioned previously, you require to clean the project, but that is a bit difficult thing because every folder is a Guid, and you do not know which one to clear, thus requiring you to delete everything. Starting with 0.33.0 version of the plugin you can automatically do that from within the IDE as well, use CTRL + Shift + P and type, java clean, and IDE will show you the suggestion tip for, Java: Clean the Java language server workspace. Upon selection, agree and restart the IDE. It will clean the language server workspace for you.

Another approach can be, the Maven tools within the IDE. If you have this plugin installed, you can use the side bar and utilize the Maven project helper options to perform actions like, clean, install, and package etc. For example, here is the project I am having and the options this shows,

enter image description here

That can be used, graphically, to manage your Maven-based projects. Also, this would work with the Java Extension Pack, not sure yet as to how it would behave with other extensions.

Original Author Afzaal Ahmad Zeeshan Of This Content

Solution 3

For me: CMD + Shift + P
Then type “Java: Clean Java language Server Workspace”

Note: This will reload/restart vscode as well.

Update:
This appears to not fix it anymore for me. In my case I am using a gradle project, and needed to set the rootProject.name in the settings.gradle to be the same as the folder name that the project is in.

Original Author TigerBear Of This Content

Solution 4

I faced this issue after creating a whole Java project in one computer and then trying to run it on another computer.

After doing everything said in the other answers, what really made VS Code compile was to open each single project java file in VS Code and save it (a simple Ctrl + S). Maybe there is a simpler way of doing it, but that is what worked for me and I hope this helps anyone stuck in this issue.

Original Author LucianoBAF Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment