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

"Cannot find symbol"

Open swarnendubiswas opened this issue 7 years ago • 9 comments

VS Code shows a "Cannot find symbol" error with the red squigly for several symbols but "Go to definition" works which means the definition is available.

Environment
  • Operating System: Ubuntu 18.04
  • JDK version: 1.8.0_171
  • Visual Studio Code version: 1.23.1
  • Java extension version: 0.26.0
Steps To Reproduce
  1. Open the attached dummy project in VS Code.
Current Result

You should see several errors related to "cannot find symbol". However, navigation or "Go to definition" works on these symbols.

Expected Result

The red squiggly lines should not appear since I think the symbols are indeed available.

Additional Informations

The VS Code settings.json file is also attached. java-symbols.zip

swarnendubiswas avatar Jun 03 '18 20:06 swarnendubiswas

Indeed, for some reason LineAddress can't be resolved immediately. but as soon as IntegerVariantTypes.java is opened, the compilation errors disappear. Might be caused by LineAddress being an inner class in a file that's doesn't define the IntegerVariantTypes class. Same project opens fine in Eclipse.

fbricon avatar Jun 07 '18 20:06 fbricon

I have the same problem.

What is the solution?

alejandrosaucedo avatar Nov 21 '18 16:11 alejandrosaucedo

I got this similar problem after I disable and enable Maven Plugin, before that everything worked like a charm, firstly I disabled Maven plugin, and restarted, then I started to see those annoying errors, I then re-enabled maven plugin, unlucky, those errors are still there, unable to eliminate no matter what I do. But my code runs without any problem.

neesonqk avatar Jan 21 '19 03:01 neesonqk

@neesonqk Those errors because of the inner classes. Could you call "Java: Force Java Compilation" to see whether your issue persists.

yaohaizh avatar Jan 21 '19 03:01 yaohaizh

@yaohaizh the issue still persists.

image

image

neesonqk avatar Jan 21 '19 03:01 neesonqk

My bad, my problem is that, I incidentally installed java linter extension when I disable Maven Plugin...

By uninstalling java linter I am able to eliminate those annoying errors.

neesonqk avatar Jan 21 '19 04:01 neesonqk

@neesonqk Those errors because of the inner classes. Could you call "Java: Force Java Compilation" to see whether your issue persists.

hey, when i try doing mine, it just says a variable is not used. But it should still be working like charm. I'm trying to make my discord bot online with discord jda. Could you maybe review my code? here

my code :

package hoppity.Hops;

import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.JDABuilder;

public class Patootie { public static void main(String[] args) throws Exception { JDA jda = JDABuilder.createDefault("Nzk2ODc0NTU3MjQzOTE2MzQ4.X_eRQw.ALNht8H0ZdCSRYN46rPpoigzMvs").build();

}

}

console log :

Patootie.java:3: error: package net.dv8tion.jda.api does not exist import net.dv8tion.jda.api.JDA; ^ Patootie.java:4: error: package net.dv8tion.jda.api does not exist import net.dv8tion.jda.api.JDABuilder; ^ Patootie.java:8: error: cannot find symbol JDA jda = JDABuilder.createDefault("Nzk2ODc0NTU3MjQzOTE2MzQ4.X_eRQw.ALNht8H0ZdCSRYN46rPpoigzMvs").build(); ^ symbol: class JDA location: class Patootie Patootie.java:8: error: cannot find symbol JDA jda = JDABuilder.createDefault("Nzk2ODc0NTU3MjQzOTE2MzQ4.X_eRQw.ALNht8H0ZdCSRYN46rPpoigzMvs").build(); ^ symbol: variable JDABuilder location: class Patootie 4 errors

ghost avatar Jan 07 '21 23:01 ghost

I'm not sure why these solutions didn't work for me, but uninstalling the Java extension by Oracle Corporation solved it!

DerMertEr avatar Jul 26 '25 07:07 DerMertEr

I'm not sure why these solutions didn't work for me, but uninstalling the Java extension by Oracle Corporation solved it!

works for me too

ishaanabhinav avatar Nov 12 '25 09:11 ishaanabhinav