Visual Studio Code - Java - Import Errors and More

Reed Hermes :

Just starting working on an existing project at work and wanted to use Visual Studio Code as my editor (I have used it for a recent Rails project and loved it so wanted to try it with Java).

However, whenever I try to open one of the projects I receive a ton of different errors including:

  • When importing java.io, java.util, or anything similar, the error:

    "The import of java.io (or java.util) cannot be resolved"

  • Existing classes have an error:

    "The implicit super constructor is undefined for default constructor. Must define explicit constructor"

  • Other random "cannot resolve to a type" errors.

All of these seem to stem from some sort of setting error I have with VS Code but can seem to find what it is. I have already uninstalled and reinstalled the RedHat plug-in that enables the Java language for VS Code. I have tried setting the java_home setting in the extension to the direct location of the install but that didn't work. Tried uninstalling and reinstalling java and that also didn't work.

My operating specs are as follows

  • OS: MacOS Sierra

  • VS Code version 1.15.1

  • JDK version 1.8.0.144

Any idea on what may be causing this? Do you think it may be an error in how I have VS Code set up or if its an error (or rather incompatibility) with how the existing project have been setup? Thanks in advance.

toreyhickman :

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

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=425186&siteId=1