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/
.
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).
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,
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.