121

I just tried to send a Maven-based project to another computer and HORROR, red markers everywhere!!

However, mvn clean install is building just fine.

Quickly, I noticed that Lombok is not generating getters and setters for my classes, although the @Getter and @Setter are being correctly recognised by Eclipse.

Both computers use the same Maven version (3.0.4) but different JDKs (1.6_23 and 1.6_33). They both use Eclipse Indigo 32 bit. Do you have an idea about how to solve the problem?

Sae1962
  • 1,020
  • 14
  • 29
Heetola
  • 4,431
  • 7
  • 26
  • 44
  • possible duplicate of [Cannot make Project Lombok work on Eclipse (Helios)](http://stackoverflow.com/questions/3418865/cannot-make-project-lombok-work-on-eclipse-helios) – Pureferret Jul 02 '13 at 19:56
  • For full instructions, see http://stackoverflow.com/questions/3418865/cannot-make-project-lombok-work-on-eclipse-helios/3425327#3425327 . This also incluses how to start Eclipse via a shortcut. – Roel Spilker Aug 06 '12 at 08:11
  • I did all the above steps BUT it wasn't working still. I looked at pom.xml again and commented out which came by default. I later add this but commented it out as well. – logixplayer Nov 22 '19 at 06:02

23 Answers23

172

When starting with a fresh eclipse installation you, in fact, need to "install" Lombok before being able to use it.

  1. Go where you Lombok jar is (e.g. (e.g. you can find in ~/.m2/repository/org/projectlombok/lombok/1.16.10/lombok-1.16.10.jar), run it (Example: java -jar lombok-1.16.10.jar). A window should appear, browse to your eclipse.exe location.
  2. Click on install.
  3. Launch Eclipse, update project configuration on all projects and voila.
Sae1962
  • 1,020
  • 14
  • 29
Heetola
  • 4,431
  • 7
  • 26
  • 44
  • 20
    If even after doing above steps it doesn't work, then EXIT and START eclipse again. Simple File->Restart doesn't work. Explicit EXIT and Start is necessary. – nanosoft Mar 04 '15 at 21:26
  • 1
    I believe I did this while eclipse was closed – Heetola Mar 05 '15 at 14:30
  • 2
    If it was closed then fine it work with next start. But if it is already started and Explicit EXIT and start is required. – nanosoft Mar 05 '15 at 19:46
  • 3
    Well done @Elidosa --- It's working, but yes need to Exit and start eclipse , only restart does't work – SMT Feb 10 '16 at 05:36
  • 1
    I also needed to clean the projects to remove compilation errors – Aditya Jan 13 '17 at 10:43
  • thanks nanosoft!.. I was doing File>restart and it wasn't working..had tried everything – Vikash Apr 12 '18 at 09:44
  • when I am trying to execute jar getting "Invalid or corrupt jarfile lombok-1.18.2.jar" What to do??? – Naseer Mohammad Oct 17 '18 at 15:38
  • If any of the above still don't work, ensure the project can be otherwise built/compiled using maven/gradle. Then, delete the project from your workspace, and re-import it, ensuring the project build invocation completes successfully with lombok references in place. – sanimalp Apr 05 '19 at 15:57
  • what in case of Netbeans? Where can I find Netbeans 12.3 location on ubuntu! I tried to /snap, but not working – Demobilizer May 13 '21 at 08:10
93
  • If you use STS. You must have Lombok installed in your Eclipse by running lombok-xyz.jar

  • Please Try the Following the Steps:

    1. Include pom in Maven .
    2. Exit/Shutdown STS
    3. Find lombok Jar in ~/.m2/repository/org/projectlombok/lombok/version.x
    4. From Command Prompt/Shell java -jar lombok-1.x.y.jar Project Lombok Installer

    5. Start STS

Thats all.

EDIT: I did this and was still showing errors, as mentioned in the comments. So I updated the project: right-click on project -> Maven -> Update Project and the errors disappeared.

GoutamS
  • 2,751
  • 17
  • 23
  • Still I am facing the issue not sure whats wrong is going on ? – Pra_A Sep 30 '17 at 19:34
  • Do you have any error message? Can you import the class in your Pojo Files? – GoutamS Oct 05 '17 at 14:24
  • @Prateek In case of not working, please change lombok version.And try again – GoutamS Nov 21 '17 at 14:41
  • 1
    I download the lombok.jar manually, ran it and later restarted eclipse and rebuilded projects, it's worked!... – ArifMustafa May 05 '18 at 05:45
  • I had same issue tried everything but didn't work. Then what I did is, I installed fresh and before doing anything I installed Lombok. It worked. Also, make sure that you start with the fresh workspace. It didn't work with the old one. – Rajeev May 03 '20 at 22:30
54

Note that if you're using IntelliJ, you'll want to install the Lombok plugin (available from IDE settings) and also enable annotation processing.

PacificSky
  • 3,322
  • 2
  • 22
  • 24
8

If you use eclipse. You must have lombok installed in your Eclipse by running lombok-xyz.jar (e.g. you can find in ~/.m2/repository/org/projectlombok/lombok/1.12.6/lombok-1.12.6.jar).

As the window of installation opened, you must choose the location of your Eclipse. And let it install lombok inside. You must restart your Eclipse afterwards.

sancho21
  • 3,219
  • 33
  • 41
8

Download Lombok Jar, let’s maven do the download on our behalf :

 <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.16.18</version>
    </dependency>

Now... mvn clean install command on the newly created project to get this jar downloaded in local repository. Goto the jar location, execute the command prompt, run the command : java -jar lombok-1.16.18.jar

enter image description here

click on the “Specify Location” button and locate the eclipse.exe path LIKE : enter image description here

finally install this by clicking the “Install/Update”

Tiago Medici
  • 1,030
  • 12
  • 13
6

These are command line instructions where the above Graphical version is not available or you can not open the Lombok jar file by double clicks, like in Ubuntu.

At the time of writing using Lombok is not straightforward as just adding a dependency in your POM xml file and adding the annotation. These are the next steps:

1) Locate where your Lombok jar file is downloaded by maven; Usually it is in .m2 folder inside your home directory. Then execute the following command.

java -jar lombok-1.16.18.jar install <path of where your IDE is installed>

example usage:

java -jar lombok-x.xx.xx.jar install ~/Downloads/spring-tool-suite-3.9.1.RELEASE-e4.7.1a-linux-gtk-x86_64/sts-bundle/sts-3.9.1.RELEASE/

the above command basically makes a configuration update in your IDE .ini or configuration file something like below:

-javaagent:/home/neshant/Downloads/spring-tool-suite-3.9.1.RELEASE-e4.7.1a-linux-gtk-x86_64/sts-bundle/sts-3.9.1.RELEASE/lombok.jar

this ensures that the @Data or @Getter or @Setter annotations are understood by the IDE. It is weird that it had to be so complex.

5

If you are using maven and Eclipse, must be installed manually.

  1. Verify pom

 <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.10</version>
            <type>jar</type>
        </dependency>
  1. go to Maven Dependencies

enter image description here

  1. Right click in the library and Run as Java aplication

enter image description here

  1. Especify location IDE, install and close IDE (Eclipse). enter image description here
  • I followed all steps you described but with eclipse 2019-12 and lombok 1.18.12, eclipse does not recognize that there is a \@getter or \@setter annotation in my model. Is there even a getter or setter generated by lombok? – Ben May 21 '20 at 09:42
3

just adding the dependency of Lombok is not enough. You'll have to install the plugin of Lombok too.

You can get your Lombok jar file in by navigating through (Only if you have added the dependency in any of the POM.)

m2\repository\org\projectlombok\lombok\1.18.12\lombok-1.18.12

Also, if Lombok could not find the IDE, manually specify the .exe of your IDE and click install.

Restart your IDE.

That's it.

If you face any problem,

Below is a beautiful and short video about how to install the plugin of Lombok.

Just to save your time, you can start from 1:40.

https://www.youtube.com/watch?v=5K6NNX-GGDI

If it still doesn't work,

Verify that lombok.jar is there in your sts.ini file (sts config file, present in sts folder.)

-javaagent:lombok.jar

Do an Alt+F5. This will update your maven.

Close your IDE and again start it.

Ashish Singh
  • 135
  • 8
  • 1
    How come this answer didn't have even a single vote. THis really helped. Thanks a ton. – sofs1 May 23 '20 at 11:27
3

If you use STS. You must have Lombok installed in your Eclipse by running lombok-abc.jar

Please Following the Steps:

-Include pom in Maven . -Exit/Shutdown STS(must) -Find lombok Jar in ~.m2\repository\org\projectlombok\lombok\1.18.12 -From Command enter image description here

After then enter image description here

After then select the STS.exe enter image description here

After then click to update/update

enter image description here

then Quit Installer

Happy Coding

Blockquote

Rajat Kumar
  • 791
  • 5
  • 6
2

For Sprint STS - Place the lombok.jar file in the eclipse/sts exe folder and add the following entry to the STS.ini.

-javaagent:lombok.jar
GabrielOshiro
  • 6,951
  • 4
  • 40
  • 53
ManishSingh
  • 1,339
  • 9
  • 10
1

When using lombok on a fresh installation of Eclipse or STS, you have to:

  1. Install the lombok jar which you can get at https://projectlombok.org/download. Run the jar (as Administrator if using windows) and specify the path to your Eclipse/STS installation.

  2. Restart your IDE (Eclipse or STS)

  3. Give some time for eclipse to generate the class files for lombok (Might take a up to 4 mins in some cases)

Fua
  • 19
  • 2
1

For Spring ToolSuite 4 on Mac, they renamed the ini to SpringToolSuite4.ini.

You can either rename or copy it to STS.ini to be recognized by lombok. Then copy it back to the original name to be read by the IDE. (Haven't tried if symbolic links work though.)

Chad
  • 590
  • 6
  • 16
1

Download Lombok Jar File https://projectlombok.org/downloads/lombok.jar

Add maven dependency:

   <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>1.16.18</version>
   </dependency>   

Start Lombok Installation java -jar lombok-1.16.18.jar

find complete example in this link:
https://howtodoinjava.com/automation/lombok-eclipse-installation-examples/

Pritam Banerjee
  • 15,297
  • 10
  • 71
  • 92
zedtimi
  • 176
  • 6
1

I am using Red hat Jboss developer studio. I solved this issue by:

  1. The project has lombok dependency. First look into your .m2 repository and find the lombok jar

  2. Double click on the jar, you will see installer there specify the path for IDE like C:\Users\xxx\devstudio\studio\devstudio.exe

  3. Restart the IDE and update the maven project the error will go

MS Berends
  • 2,677
  • 1
  • 21
  • 35
kranti
  • 69
  • 1
  • 6
  • 1
    Welcome to StackOverflow! Please try to write your answers more readable, by using correct lists and `markdown language like this`. – MS Berends Aug 21 '18 at 20:04
1

1) Run the command java -jar lombok-1.16.10.jar. This needs to be run from the directory of your lombok.jar file.

2) Add the location manually by selecting the eclipse.ini file(Installed eclipse directory). Through “Specify location

Note : Don't add the eclipse.exe because it will make the eclipse editor corrupt.

How to add the eclipse.ini file

1

I also encountered this issue, for my case, it's because I upgrade my IntelliJ IDEA without upgrading the Lombok plugin. So they are incompatible.

Vikki
  • 1,317
  • 1
  • 10
  • 18
1

What I had to do was to install lombok in the eclipse installation directory.

Download the lombok.jar from here and then install it using the following command:

java -jar lombok.jar

After that make sure that the lombok.jar is added in your build path. But make sure you don't add it twice by adding once through maven or gradle and once again in eclipse path.

After that clean and build the project again and see all the errors go away.

Pritam Banerjee
  • 15,297
  • 10
  • 71
  • 92
1

Intellij User, make sure you have 3 things,

  1. Lombok dependency
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.8</version>
            <scope>provided</scope>
        </dependency>
  1. IntelliJ plugin for Lombok

  2. Lombok annotation, like @Getter @Setter (make sure it is coming from lombok and not from somewhere else)

and it should work.

Rishabh Agarwal
  • 1,109
  • 1
  • 9
  • 19
0

In mac os lombok will not be able to find eclipse location. please click on specify location and go to the eclipse installed folder you can find the eclipse.ini file select that

enter image description here

Lijo
  • 4,738
  • 1
  • 41
  • 55
0

Solution for Eclipse IDE:

1. Maven dependency in pom.xml

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <optional>true</optional>
</dependency>

2. Go to Maven dependency jar >> Right click >> Run As >> Java Application

3. select Socket Server and Click OK

ch.qos.logback.classic.net.SimpleSSLSocketServer
ch.qos.logback.classic.net.SimpleSocketServer

4. Show message on console like:

Wrong number of arguments. Usage: java ch.qos.logback.classic.net.SimpleSocketServer port configFile

Jimmy
  • 282
  • 1
  • 10
0

I spent full day, you can do it this way:

  1. Add to maven lombok
  2. Install eclipse
  3. Download lombok
  4. Copy to eclipse folder
  5. Add to file eclipse.ini next text -javaagent:lombok.jar
  6. Active annotation processing in select project (not the parent)
    -> properties -> Java compiler -> annotation processing Select Enable project specific settings Select all Enable checkbox
  7. Restart and it should work . test ubuntu 20.04 and eclipse 2021 year
marc_s
  • 675,133
  • 158
  • 1,253
  • 1,388
-1

Remove @Getter from private static field.

https://github.com/rzwitserloot/lombok/issues/1493

-1

If you are using maven , Go to maven dependencies in your project structure then run lombok jar as java project it will install it then exit and start eclipse

akshay
  • 1