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
- on
settings.json
file, setjava.home
to"/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home"
- reload window
- open a java file
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 6
- Comments: 22 (1 by maintainers)
Links to this issue
Commits related to this issue
- Send message.incompleteClasspathDetected according to preferences Required to fix https://github.com/redhat-developer/vscode-java/issues/107 Signed-off-by: Fred Bricon <fbricon@gmail.com> — committed to fbricon/eclipse.jdt.ls by fbricon 8 years ago
- Send message.incompleteClasspathDetected according to preferences Required to fix https://github.com/redhat-developer/vscode-java/issues/107 Signed-off-by: Fred Bricon <fbricon@gmail.com> — committed to fbricon/eclipse.jdt.ls by fbricon 8 years ago
- Add option to disable incomplete classpath warning. Fixes #107 Signed-off-by: Fred Bricon <fbricon@gmail.com> — committed to fbricon/vscode-java by fbricon 8 years ago
- Send message.incompleteClasspathDetected according to preferences Required to fix https://github.com/redhat-developer/vscode-java/issues/107 Signed-off-by: Fred Bricon <fbricon@gmail.com> — committed to fbricon/eclipse.jdt.ls by fbricon 8 years ago
- Send message.incompleteClasspathDetected according to preferences Required to fix https://github.com/redhat-developer/vscode-java/issues/107 Signed-off-by: Fred Bricon <fbricon@gmail.com> — committed to eclipse-jdtls/eclipse.jdt.ls by fbricon 8 years ago
- Add option to disable incomplete classpath warning. Fixes #107 Signed-off-by: Fred Bricon <fbricon@gmail.com> — committed to redhat-developer/vscode-java by fbricon 8 years ago
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:
Actually, the plugin supports Eclipse files:
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:
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