vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Import Problem : ..cannot be resolved as a type

Open baptleduc opened this issue 2 years ago • 1 comments

Hi, I'm new to Java and am using Visual Studio Code (VSCode) for my development. I’ve encountered a problem when creating a package named "robot" located in "src/robot". The Java linter indicates that a class I used from the default package (located in "src") cannot be resolved as a type. I use a makefile to compile my code and I don't use maven or anything else.

Here is the error I have : image

Here is my project structure : image

Environment
  • Operating System: WSL Ubuntu 22.04.4 LTS
  • JDK version: 23.0.1
  • Visual Studio Code version: 1.94.2
  • Java extension version: 0.29.0

[Please attach a sample project reproducing the error] Please attach logs

Current Result

..cannot be resolved as a type

Expected Result

.

Additional Informations

baptleduc avatar Oct 25 '24 13:10 baptleduc

As per the Java Spec, you can't reference classes from the default package, in another package. See https://stackoverflow.com/a/2193298/753170

fbricon avatar Oct 25 '24 13:10 fbricon