codenubie
codenubie

Reputation: 71

Java/VSCode "file.java is not on the classpath of project, only syntax errors are reported"

Hi I'm new to java and keep getting this error on and on in vs code. How do I solve this?

Upvotes: 6

Views: 12937

Answers (4)

Vojat
Vojat

Reputation: 1

First click on the Java status menu and then Clean Workspace Cache and the warning should go away.

Upvotes: 0

Charleeoh
Charleeoh

Reputation: 13

Tried other solutions here but didn't work for me, what eventually worked for me was:

  1. Moving the java file to a folder. (A project folder)
  2. Make sure the project folder is opened on the explorer tab in VS codes

Upvotes: 0

Thuan Tran
Thuan Tran

Reputation: 447

Press "Ctrl + Shift + P", choose "java : Clean java Language Server workspace". If not run, right click on src, choose "add folder to java source path"

Upvotes: 11

dikay
dikay

Reputation: 378

You can solve this by opening your current project folder in vs code, then navigate to "Java Projects" > "properties" > "clean workspace".

Upvotes: 5

Related Questions