vscode-java: [Java] The declared package "com.github.****" does not match the expected package ""
I try to make a library for the first time in VSCode (I have done this before in IntelliJ and Eclipse).
My workspace looks like this:
In LemmingsWalker.java I have: package com.github.lemmingswalker;
.
Which gives me the following error:
[Java] The declared package “com.github.lemmingswalker” does not match the expected package “”
Environment
- Operating System: Mac OSX
- JDK version: jdk1.8.0_144
- Visual Studio Code version: Version 1.14.2 (1.14.2)
- Java extension version: 0.8.0
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 21 (5 by maintainers)
I have been encountering this issue recently as well. My solution was to add
to
.vscode/settings.json
.I figured out what it is (still seems like a bug). I wanted to make a sample project so made a copy of the directory. While opening this in VSCode the error was gone.
If I rename the original directory the error is gone as well. If I rename it back to what it was the error comes back again. So I assume there is a bug in the cache validation?
This was a problem for me too. I navigated to the configure class path tab through the “java projects” tab at the bottom left of the screen. From there, i removed all other paths apart from the default. this solved my problem. The “java.project.sourcePaths”: [“”]" solution does this.