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

Created on 27 Nov 2016  路  18Comments  路  Source: redhat-developer/vscode-java

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
enhancement

Most helpful comment

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.

All 18 comments

So am i,but my operating system is win10.

I use Win10 and I have set up both my PATH & CLASSPATH properly. But I get the same warning message on starting VSC.

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.

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.

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?

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

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.

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?

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

@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?

@EldarKersebaum you should be able to get content-assist and navigate between classes in the same folder with ctrl+click, provided these files have been opened once in vscode. This is a current technical limitation. But if you click on Don't show again, that should be enough for a small number of classes.

Please open a separate feature request if you think we could improve that

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.

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

Then are there any plans to support Gradle projects separately from eclipse projects? When I create a build.gradle file, vscode generates eclipse files even though it's not an eclipse project.

Also it would be nice if it would follow VS code conventions: Put the plugin configuration into .vscode folder, do not litter my project with .classpath, .project, .settings.

because we're using an headless eclipse process behind the scenes, we have no way to control where those .classpath, .project, .settings. files can be stored. It's unlikely to change unfortunately.

1094 and same at https://github.com/microsoft/vscode-java-dependency/issues/189

Project working on eclipse , but not in VSCODE. more detail in above link.

@leizongmin
try disable the extension "Language Support for Java(TM) by Red Hat";
then restart vscode, the extension will auto enable.

Was this page helpful?
0 / 5 - 0 ratings