Vscode-java: "Cannot find symbol"

Created on 3 Jun 2018  路  7Comments  路  Source: redhat-developer/vscode-java

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

bug

Most helpful comment

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.

All 7 comments

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.

I have the same problem.

What is the solution?

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 Those errors because of the inner classes. Could you call "Java: Force Java Compilation" to see whether your issue persists.

@yaohaizh the issue still persists.

image

image

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 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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zalcorshark picture zalcorshark  路  3Comments

marlinla picture marlinla  路  3Comments

larixer picture larixer  路  3Comments

ViniciusAtaide picture ViniciusAtaide  路  4Comments

protoEvangelion picture protoEvangelion  路  3Comments