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

java: cannot find symbol symbol: class Generated location: package javax.annotation

Open Nyagar-Abraham opened this issue 2 months ago • 1 comments

The error "java: cannot find symbol symbol: class Generated location: package javax.annotation" indicates that the Java compiler cannot locate the Generated class within the javax.annotation package. This typically occurs in projects that use code generation or annotations and are missing a required dependency or have an incorrect project setup.

Here are the common causes and solutions: Missing javax.annotation-api dependency. The Generated annotation is part of the javax.annotation-api library. If your project uses a build system like Maven or Gradle, you need to explicitly add this dependency.

Maven

<dependency>
       <groupId>javax.annotation</groupId>
       <artifactId>javax.annotation-api</artifactId>
       <version>1.3.2</version> <!-- Or the appropriate version for your project -->
   </dependency>

Gradle

 dependencies {
       implementation 'javax.annotation:javax.annotation-api:1.3.2' // Or the appropriate version
   }

Nyagar-Abraham avatar Sep 22 '25 06:09 Nyagar-Abraham