Sunday, April 20, 2025

LomBok annotations in the Cursor IDE settings.json to remove the erroneous lint errors

Download Lombok support in the Cursor IDE extensions 

Add the LomBok annotations in the Cursor IDE settings.json

1. Find your Lombok JAR path
If you installed Lombok via the extension, it’s usually somewhere like:

d ~/.vscode/extensions

find . -name "lombok*.jar"

Or you can download the lombok.jar yourself manually and place it somewhere.


2. Configure Cursor settings for Java to load Lombok

In Cursor, open your settings.json (Ctrl/Cmd + Shift + P → "Preferences: Open Settings (JSON)") and add this line under Java settings:

json
"java.jdt.ls.vmargs": "-javaagent:/path/to/lombok.jar"

Example:

json
{ "java.jdt.ls.vmargs": "-javaagent:/Users/yourname/.vscode/extensions/lombok-extension-folder/lombok.jar" }

Make sure:

  • The path is correct and points to your lombok.jar.

  • No extra spaces inside the path.

  • If your path has spaces, wrap it in quotes inside the argument, like:
    -javaagent=\"/path/with space/lombok.jar\"


3. Reload the Java Language Server

After editing settings.json, do:

  • Ctrl+Shift+P → Java: Clean Workspace

  • Ctrl+Shift+P → Developer: Reload Window

  • Cursor should restart jdtls and pick up the Lombok agent correctly.


Summary:

Installing the Lombok extension alone isn't enough — you must manually tell the Java server to preload Lombok at JVM startup via -javaagent.

{
"window.commandCenter": 1,
"redhat.telemetry.enabled": false,
"java.jdt.ls.vmargs": "-javaagent:/Users/<usename>/.vscode/extensions/redhat.java-1.41.1-darwin-arm64/lombok/lombok-1.18.36.jar"
}

No comments:

Post a Comment