Compile Error: Cannot Find Symbol

error: cannot find symbol. symbol: variable myVariable

Quick Answer

The compiler cannot find the variable, method, or class you referenced. Check for typos, missing imports, or scope issues.

Why This Happens

This compile error means the identifier you used is not declared in the current scope. Common causes: typos in variable or method names, missing import statements, referencing a variable outside its scope, or using a class from a dependency that is not on the classpath.

The Problem

public class Main {
    public void process() {
        System.out.println(myList.size()); // myList not declared
    }
}

The Fix

public class Main {
    public void process() {
        List<String> myList = new ArrayList<>(); // Declare the variable
        System.out.println(myList.size());
    }
}

Step-by-Step Fix

  1. 1

    Identify the missing symbol

    Read the error for the symbol name and type (variable, method, class). Check the location in the code.

  2. 2

    Check for common causes

    Look for typos, missing imports, wrong package, variable declared in a different scope, or missing dependency.

  3. 3

    Fix the reference

    Correct the typo, add the import, declare the variable, or add the dependency to your build file.

Bugsly catches this automatically

Bugsly's AI analyzes this error pattern in real-time, explains what went wrong in plain English, and suggests the exact fix — before your users even report it.

Try Bugsly free