To fix the “java.lang.IllegalAccessError: class lombok.javac.apt. LombokProcessor cannot access class com.sun.tools.javac.processing. JavacProcessingEnvironment” error in Java, there are several solutions we have tested that work. Follow the article to better understand.
What causes the error?
The error happens because you use the Lombok plugin to generate setters and getters for the area of a particular category. I have the following solutions.
How to solve “java.lang.IllegalAccessError: class lombok.javac.apt. LombokProcessor cannot access class com.sun.tools.javac.processing. JavacProcessingEnvironment” in Java
Use @Data( Lombok)
If you want to instantiate an Information class with full functions like getter, setter, toString, equals, hashCode and constructor, it will take a lot of time and cumbersome syntax. So I would suggest you use @Data to generate the above functions automatically during chapter building so you can optimize your time and focus on the more essential parts.
Example:
import lombok.Data; @Data public class Information { private String fullname; private Long id; }
Update your Lombok
Lombok is a library in Java that automatically generates functions like setters/getters, constructors, and toString,…
The outstanding advantage of the Lombok library is that it helps to streamline the lengthy code of frequently repeated operations such as setters/getters and constructors to help programmers optimize working time.
If you get this error, please update your Lombok to at least version 1.18.20, so the program can run smoothly.
To use Lombok annotations, we add the Lombok dependency to pom.xml:
Example:
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.20</version> <scope>provided</scope> </dependency>
Or you can download it at https://projectlombok.org/download.
Add Plugin to pom.xml
You can add Plugins to pom.xml able to resolve the error.
Example:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>16</source> <target>16</target> <!-- <release>16</release>--> <fork>true</fork> <compilerArgs> <arg>--enable-preview</arg> <arg>-Xlint:all</arg> <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg> <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg> <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg> <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg> <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg> <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg> <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg> <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg> <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg> <arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED</arg> </compilerArgs> <!--for unmappable characters in classes--> <encoding>UTF-8</encoding> <showDeprecation>true</showDeprecation> <showWarnings>true</showWarnings> <!--for lombok annotations to resolve--> <!--contradictory to maven, intelliJ fails with this--> <annotationProcessorPaths> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.16</version> </path> </annotationProcessorPaths> </configuration> </plugin>
Downgrade the current Java version
If you have installed the Lombok library and still get the “java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment” error, then I think you should downgrade your Java version. Maybe the error will be solved.
Summary
Please read this article if you encounter “java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment” in Java. If you have any questions about this issue, leave a comment below. I will answer your questions. Thanks for reading!
Maybe you are interested:
- Error: Non-static Variable/Method ‘#’ Cannot be Referenced from a Static Context
- Exception in Thread “Main” Java.util.nosuchelementexception
- ERROR : ‘compileJava’ task (current target is 11) and ‘compileKotlin’ task (current target is 1.8) jvm target compatibility should be set to the same Java version in Java

My name is Jason Wilson, you can call me Jason. My major is information technology, and I am proficient in C++, Python, and Java. I hope my writings are useful to you while you study programming languages.
Name of the university: HHAU
Major: IT
Programming Languages: C++, Python, Java