vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Warning: Classpath is incomplete. Only syntax errors will be reported.

Open leizongmin opened this issue 10 years ago • 22 comments

I set java.home to "/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home", when I open a java file, the vscode shows the warning message "Classpath is incomplete. Only syntax errors will be reported.", what's wrong? How can I fix this issue?

This warning message is from this file: https://github.com/gorkem/java-language-server/blob/74efc7ac1d9c9abb6728864111e33b1eb4d5e483/org.jboss.tools.vscode.java/src/org/jboss/tools/vscode/java/internal/handlers/DocumentLifeCycleHandler.java#L114

Environment
  • Operating System: macOS Sierra 10.12.1
  • JDK version: 1.8.0_102
  • Visual Studio Code version: 1.7.2
  • Java extension version: 1.8.0_102
Steps To Reproduce
  1. on settings.json file, set java.home to "/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home"
  2. reload window
  3. open a java file

leizongmin avatar Nov 27 '16 09:11 leizongmin

In VS Code just right-click on the src (the folder which contains .java files) folder and select the " Add folder to Java source path" option. If it didn't' worked, then try to remove it first by selecting "remove the folder from Java source path" and then adding it again.

Restart once when done. Hope it works for you.

abdeali004 avatar May 14 '21 06:05 abdeali004

This warning is displayed when you open a single java file, because at that point, no classpath can be configured thus no information on types other than the default JDK can be provided. In that case, only syntax errors are reported. Else you'd get compilation errors all over the place. Javadoc and Navigation to classes from the JDK are available.

You need to open a folder containing a pom.xml, or at least default eclipse setting files, so that a complete classpath and project hierarchy can be set.

I cannot find the pom.xml file, can u please tell me where it is? My jdk is currently 16.0.1 version.

Rastra17 avatar Jun 19 '21 17:06 Rastra17