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

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

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 6
  • Comments: 22 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Yes, I opened a folder that contains a pom.xml file, it did not show this warning again.

I think the warning message would be more friendly, such as Cannot find pom.xml or eclipse setting files. Classpath is incomplete. Only syntax errors will be reported. will help people quick understand what’s wrong with it.

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.

Just leaving a note here for people who are trying to make this work…

The key is to not think of this as Java support for VS Code. It’s an adapter to make Eclipse’s Java support work with VS Code.

If you try to make it do anything but the things it explicitly support (reading eclipse project files and some other things) you are in for a world of hurt. Instead, just install Eclipse temporarily, Google how to import your project into Eclipse, and then take the .project and .classpath files generated by Eclipse and put those in your project so VS Code can find and use them.

Getting a project with an Ant build to work with VS Code was a total nightmare until I tried this approach. Just a couple of clicks to import the ant project into Eclipse, then copy the project files and bam everything just works.

Maybe in the future this plugin will also borrow Eclipse’s excellent project import features, but until then don’t waste your time trying to make your project work with VS Code directly and go through Eclipse project import instead.

If you do need to show the warning then at least making it so that it can be dismissed for the whole of the remainder of the current session until VS Code is restarted would make it less annoying.

Cheers to rvolgers!

The readme is misleading:

  • Maven pom.xml project support
  • Basic Gradle Java project support

Actually, the plugin supports Eclipse files:

.classpath
.project
.settings/org.eclipse.jdt.core.prefs

And it would be worth mentioning this in the readme.

Regards Peter

I just got the same unfriendly message. Is the intention to let it stay like that?

As insight:

  • “Classpath is incomplete”. Huh? What is it lacking? What is a complete classpath?
  • “Only syntax errors will be reported”. Huh? What am I missing? What other kinds of errors can I get?

Is there a way to disable the warning? I often use VSCode when I want to look at single files outside of a project and in that case the warning is annoying. Maybe it could be changed to a warning in the status bar?

@fbricon The link explains pretty well what to do. The problem is that I feel left alone with how to do it. I am only writing small snippets and tests, thus I have all my files in the current directory. I don’t need a full bloated pom.xml After looking around with pom.xml I only found examples for classpath = "src"

Wouldn’t it make sense to assume curr_directory is the classpath for standalone files?

Does https://github.com/redhat-developer/vscode-java/wiki/"Classpath-is-incomplete"-warning help? We should probably link to that page directly from the warning

@peterzeller we opted for the warning to display because we think that linked mode can throw a developer that uses vscode to build an application off track. However, I do agree that the warning will become annoying after a while. Alternates that comes to my mind

  • A new setting to suppress warnings.
  • Show warnings for first n times and switch to status bar.