79

I have followed the tutorial here http://projectlombok.org/

but after adding import and @Data nothing happens.

Does it work on eclipse helios ?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
user310291
  • 36,946
  • 82
  • 271
  • 487
  • If you already tried other methods but it still doesn't work, you can try this [this answer](https://stackoverflow.com/a/47506158/1522490). I fixed it after spending hours to investigate – Le Quang Nhan Nov 27 '17 at 08:03
  • Try this https://stackoverflow.com/a/69332138/3637115 . It helped me. – Tejas Sep 26 '21 at 05:42

22 Answers22

149

You not only have to add lombok.jar to the libraries, but also install it by either double-clicking the lombok jar, or from the command line run java -jar lombok.jar. That will show you a nice installer screen. Select your Eclipse installation and install.

Afterwards, you can check if the installer has correctly modified your eclipse.ini:

-vmargs
...
-javaagent:lombok.jar
-Xbootclasspath/a:lombok.jar

If your Eclipse was already running, you have to Exit Eclipse and start it again. (File/Restart is not enough)

If you are starting Eclipse using a shortcut, make sure that either there are no command line arguments filled in, or manually add -javaagent:lombok.jar -Xbootclasspath/a:lombok.jar somewhere after -vmargs.

Recent editions of Lombok also add a line to the About Eclipse screen. If Lombok is active you can find a line like 'Lombok v0.11.6 "Dashing Kakapo" is installed. http://projectlombok.org/' just above the line of buttons.

If for some reason, usually related to customized eclipse builds, you need to use the full path, you can instruct the installer on the command line to do so:

java -Dlombok.installer.fullpath -jar lombok.jar

Roel Spilker
  • 32,258
  • 10
  • 68
  • 58
  • Why is this so with lombok? – AncientSwordRage Jul 02 '13 at 20:07
  • 1
    Sorry, I don't understand your question. What exactly do you want to know? – Roel Spilker Jul 04 '13 at 11:40
  • Thanks. Manually adding the -vmargs parameters was not enough for me; Eclipse would briefly show the splash window and exit. I had to run the `/path/to/java/java.exe -jar lombok.jar` and tell it where Eclipse was installed before it worked. In addition to whatever else it did, it added those parameters to the end of my eclipse.ini file and then starting Eclipse worked just fine. – Brian White Nov 22 '13 at 02:06
  • 2
    If you happen to be running a customized Eclipse Helios distribution then you may have to use the full path to lombok.jar in both the vm arguments. There's a way to do that with the installer by running it like so: `java -Dlombok.installer.fullpath -jar lombok.jar`. See [here](https://github.com/rzwitserloot/lombok/commit/b47e87f8735f2e498beb9372bbd6fb4347e27e34) for more details. – chrisjleu Feb 05 '14 at 15:05
  • Thanks, I've added this to the answer. – Roel Spilker Mar 08 '14 at 16:22
  • It's not intuitive, but the installer is asking for the locations of eclipse.ini . – Scott Carlson Nov 04 '15 at 15:17
  • 6
    I was puzzled after restarting several times and the projects still being broken. Just needed to run Project->Clean. – Nate Glenn Aug 03 '16 at 06:47
  • Hi Roel, I followed the above steps to make lombok work. But when -javaagent:D:\eclipse\neon\lombok.jar -Xbootclasspath/a:D:\eclipse\neon\lombok.jar are added. My eclipse is not starting and getting crashed. Showing message an error has occured. Please let me know what should i do next to make it start. – Reetika May 06 '17 at 18:33
  • 1
    Recent versions of lombok do no longer need the -Xbootclasspath parameter – Roel Spilker May 09 '17 at 07:38
  • I have copied lombok-1.16.2.jar to my eclipse folder where eclipse.ini file is located. In eclipse.ini I have added these two line at the end of file: `-javaagent:lombok.jar -Xbootclasspath/a:lombok.jar` and eclipse restarted. eclipse IDE not getting opened and getting message as An error has occured. See the log file ..workspace.metadata.log. I am using Eclipse Neon3. Does anything extra setting required? – Vikas Jul 24 '17 at 07:25
  • Try using a full path, as suggested by https://stackoverflow.com/questions/3418865/cannot-make-project-lombok-work-on-eclipse-helios/3425327?noredirect=1#comment32599526_3425327 – Roel Spilker Jul 25 '17 at 08:53
  • 1
    Also note that you cannot change the name of the eclipse executable (eclipse.exe), because eclipse.ini won't be loaded and default configuration will be used. – tyfyh Oct 24 '18 at 21:19
  • If Eclipse was installed via Snap, as Robin479 writes: _Apparently, you can simply copy `/snap/eclipse/current/eclipse.ini` to `${HOME}/snap/eclipse/current/eclipse.ini`, where you can edit it, and it will **automatically** get picked up by the snap. Note, that both `current/` subdirs are links the actual version of the snap (e.g. `66/` in my case). You will have to repeat this procedure every time the snap is upgraded to a new version._ https://askubuntu.com/q/1051926/#comment2524961_1051927 – propatience Mar 08 '23 at 17:19
75

Did you add

-vmargs
...
-javaagent:lombok.jar
-Xbootclasspath/a:lombok.jar

to your eclipse.ini?

Because if you have (and if you have added the lombok.jar to the libraries used by your project), it works just fine with Eclipse Helios:

alt text


Ian Tegebo mentions in the comments that:

a simple "restart" was not sufficient to pick up the changed vmargs:
I needed to explicitly exit and then start again.


chrisjleu mentions in the comments:

If you happen to be running a customized Eclipse Helios (3.6+) distribution then you may have to use the full path to lombok.jar in both the vm arguments.
See commit b47e87f for more details.

boolean fullPathRequired = IdeFinder.getOS() == EclipseFinder.OS.UNIX || System.getProperty("lombok.installer.fullpath") != null;
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 19
    FWIW, a simple "restart" was not sufficient to pick up the changed vmargs: I needed to explicitly exit and then start again. – Ian Tegebo Sep 10 '11 at 08:29
  • From the answer below I have removed the reference to this answer and I've inlined the content of eclipse.ini to provide a stand alone answer. Thanks VonC. – Roel Spilker Aug 06 '12 at 08:17
  • @IanTegebo Your answer was the solution for me! You should post it as a proper answer! Thanks! – Clint Eastwood Mar 28 '13 at 15:48
  • @Jonathan I have included Ian's comment in the answer for more visibility. – VonC Mar 28 '13 at 15:52
  • Didn't work for me without running the .jar file (as per other answer). – Brian White Nov 22 '13 at 02:06
  • If you happen to be running a customized Eclipse Helios distribution then you may have to use the full path to lombok.jar in both the vm arguments. See [here](https://github.com/rzwitserloot/lombok/commit/b47e87f8735f2e498beb9372bbd6fb4347e27e34) for more details. – chrisjleu Feb 05 '14 at 15:02
  • After adding this `-javaagent:lombok.jar`, I am not able to start Eclipse Oxygen. – Raghu DV Dec 10 '17 at 06:23
  • @RaghuDV And with https://stackoverflow.com/questions/3418865/cannot-make-project-lombok-work-on-eclipse-helios/3425327?noredirect=1#comment32599526_3425327 ? – VonC Dec 10 '17 at 06:25
  • @VonC that resolved Eclipse start issue, but still I am not able to see the methods created by lombok in class outline, But the project is succesfully built, with eclipse error displaying unresolved methods. – Raghu DV Dec 10 '17 at 06:33
  • @RaghuDV OK: time to ask a separate question then. – VonC Dec 10 '17 at 06:34
54

After adding lombok and restarting eclipse or spring tools my project still failed to recognize getters and setters. Red markers everywhere!

The solution: right-click your project, go to Maven and select Update Project

After hours of searching and trying random solution, I find this to be the only solution that worked for me.

enter image description here

Forza
  • 1,619
  • 3
  • 28
  • 49
29

Please follow the following steps:- If lombok jar has already been added as dependency in eclipse, then go to project's lib folder > Locate Lombok.xx.jar > Right Click on Jar> Run as Java Application> This will launch Lombok screen as below:- enter image description here

Next, click on "Specify location" > And specify location of "Eclipse.ini" file.(Eclipse neon on Mac osX has it at -> "<Eclipse_installation_path>/jee-neon/Eclipse.app/Contents/Eclipse/Eclipse.ini").

After this, restart eclipse and Clean build project.

This worked for me.

the_D
  • 890
  • 13
  • 26
10

Don't forget to do to Project->Clean in eclipse to make sure that your classes are recompiled.

Viktor K.
  • 2,670
  • 2
  • 19
  • 30
4
  1. Copy the Lombok jar into your eclipse based IDE (Eclipse/STS etc-) install folder

    • note that the install folder is the folder that has the .ini file for your IDE
    • if you use Maven to pull in the jar, then get it from your m2 repository
    • cp ~/.m2/repository/projectlombork/lombork-1.x.jar /path/to/IDE/lombok.jar
  2. Edit the .ini file in the install folder of your IDE and add the following lines below -vmargs.

    • -javaagent:lombok.jar -Xbootclasspath/a:lombok.jar
    • note that the jar should be in the same folder as the .ini file and the name of the jar lombok.jar
  3. Restart your IDE and rebuild/maven-update your project

Rocky Inde
  • 1,511
  • 1
  • 20
  • 27
4

I can only make this work if I start the eclipse.exe directly in the eclipse installation folder. If I use a command file setting some initial JAVA_HOME and maven parameters before running the eclipse.exe it does not work and I get compiler errors on the exact same projects

  • That is because the reference to the lombok.jar file is relative to the current working directory. If you start eclipse from another path you need to change the arguments to absolute paths like `-javaagent:c:/eclipse/lombok.jar` – Maddin Jun 28 '13 at 09:37
3

This is for setup of lombok on Spring Tool Suite. Here is what I did on spring tool suite (sts-4.4.0.RELEASE) and lombok-1.18.10.jar (current latest version available in mavenrepository).

  1. If having maven project, ensure lombok dependency added to it. Else you need manually add the jar to your project classpath.

    <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.10</version> <scope>provided</scope> </dependency>

  2. Clean build the maven application. This will download lombok jar in your .m2 location by default from maven repository. The path would be org\projectlombok\lombok\1.18.10\

  3. Now open command prompt and navigate to the lombok path and execute command java -jar lombok-1.18.10.jar

    C:\xxx\xxx\org\projectlombok\lombok\1.18.10>java -jar lombok-1.18.10.jar

  4. Opens up lombok dialog box. If see message Can't find IDE Click Specify location... Provide the path to your STS root location

    My case it is C:\apps\sts-4.4.0.RELEASE\SpringToolSuite.exe

    Install/Update

  5. Install successful Click Quit Installer

  6. Now in explorer navigate to your STS root path. C:\apps\sts-4.4.0.RELEASE\ We see lombok.jar placed in the sts root path Now edit in notepad SpringToolSuite4.ini file We see following appended at the end

    -javaagent:C:\apps\sts-4.4.0.RELEASE\lombok.jar

  7. Start STS using SpringToolSuite4.exe Clean, rebuild your project.

vinsinraw
  • 2,003
  • 1
  • 16
  • 18
3

Remenber run lombok.jar as a java app, if your using windows7 open a console(cmd.exe) as adminstrator, and run C:"your java instalation"\ java -jar "lombok directory"\lombok.jar and then lombok ask for yours ides ubication.

Udo Held
  • 12,314
  • 11
  • 67
  • 93
3

This sometimes does not work if Eclipse is on one of those strange default windows paths (e.g. c:/Program files (86)/Eclipse).

In that case, do as above, then move the lombok jar to a cleaner path without spaces and braces (e.g. c:\lombok\lombok.jar) and modify eclipse.ini accordingly.

Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44
Dennis
  • 31
  • 1
3

I ran into this problem due to the missing:

-vmargs -javaagent:lombok.jar -Xbootclasspath/a:lombok.jar

as well. What is not explicitly said neither here nor in the Lombok popup message, and was not obvious to me as someone who never before had to fiddle with the eclipse.ini, is that you are NOT supposed to add that line, but instead add the last two parts of that line after the first part, which is already in the eclipse.ini file. To better illustrate, the end of the file should look something like this (bold is what matters for Lombok, the rest might be different for you):

-vm
C:/Program Files/Java/jdk1.7.0_02/bin
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx384m
-javaagent:lombok.jar
-Xbootclasspath/a:lombok.jar

Torque
  • 3,319
  • 2
  • 27
  • 39
2

If you are using windows xp and eclipse juno then it should be like this in order

-vmargs
-Dosgi.requiredJavaVersion=1.5
-Dhelp.lucene.tokenizer=standard
-javaagent:lombok.jar
-Xbootclasspath/a:lombok.jar
-Xms40m
-Xmx512m
Beau Grantham
  • 3,435
  • 5
  • 33
  • 43
Rasik
  • 21
  • 1
2

I could not install lombok.jar on my MacBook Pro because of the version of Java. I had to downgrade to Java 1.6 to install and then I reused Java 1.7 when the installation worked !

You can see the different JVM installed on your machine here : /System/Library/Java/JavaVirtualMachines

c4k
  • 4,270
  • 4
  • 40
  • 65
2

I had similar issue on MacBook Pro, I just followed the below link and issue got resolved. https://projectlombok.org/setup/eclipse

Steps followed:-

  • Download the lombok.jar
  • Double click on this jar
  • This jar will try to find the eclipse installed on the machine, but in my case it was not able to identify the eclipse though I installed on it, this could be due to softlink to the eclipse path.
  • I just specified the location of the eclipse ini file by clicking "Specify location" button
  • This jar automatically updated the entry in eclipse.ini file for javaagent
    • I added the same jar to the classpath of the project in the eclipse
    • Restarted my eclipse
Dwarak
  • 31
  • 2
  • I faced same issue on Windows-10 + JBoss Developer Studio-8.1.0.GA. Exactly same steps as mentioned by Dwarak worked for me. As I had a maven project imported inside jbdevstudio, i had to do maven --> Update Project as an extra step in the last. I noticed following changes happenned automatically, the lombok.jar got copied inside *\jbdevstudio\studio\ folder. *\jbdevstudio\studio\jbdevstudio.ini file got modified and a new line as below got added as the last line. "-javaagent:*\jbdevstudio\studio\lombok.jar" – nirmalsingh Dec 07 '18 at 07:30
1

I searched for lomob.jar in .m2 repo. Once you double click it -> Search eclipse.exe and select it. After lombok will make the required changes. Explicitly quit eclipse -> it should be fixed by now. If not do a maven Update.

Deepika Anand
  • 305
  • 3
  • 6
1

I am on Eclipse Neon, and after following the above steps, it still didnt work. import lombok.Data; was not being recognized.

After about an hour of looking around, i switched the version to 1.16.14 and it worked.

Now my thought is, whether the 1 hour spent will be a good investment for long term :-)

Mavendew
  • 131
  • 1
  • 12
1

Eclipse Oxygen - after installation of Lombok according to the process described on the Lombok page, still could not use @Log annotation.

Solution : Project --> Properties - Enable annotation processing

1

Just faced this issue (compiler errors for generated getters) and none of the proposed solutions helped.

Setup: Eclipse Oxygen (32bit), SAP_JVM (32bit), Lombok 1.16.18 (Eclipse plugin properly installed).

Created a plain new test project, which worked like a charm. Afterwards deleted the failing project and checked it out again from my Github repo, which fixed the errors. Just deleting the project from the workspace and importing it again, didn't help.

mariograf
  • 11
  • 2
1

It was little frustrating. But finally it got resolved for me with following solution.

The issue seems to be where "-javaagent:lombok.jar" is placed in your ini file. When i installed it through lombok installation. This line got added towards last parameters after -vmargs. When i moved it up next to -vmargs. the issue got resolved.

0

I am using windows 10. I followed below steps :

  • Added lombok dependency in pom.xml of my project
  • Added "-javaagent:{pathOfLombokJarInSystem}" in eclipse.ini file. Path in my case was "-javaagent:C:\Users\ {username} .m2\repository\org\projectlombok\lombok\1.18.6\lombok-1.18.6.jar"
  • Started the eclipse and did Maven > Update Project.

This resolved the issue for me.

Sonam Shinare
  • 231
  • 2
  • 3
0

I am using Eclipse Jee 2019-06 and this worked for me:

  • Download Lombok.jar
  • Open cmd and run: java -jar Lombok.jar
  • Lombok config window will open.
  • In “Specify Location” set the path of the eclipse.exe (for example C:\Users\<username>\eclipse\jee-2019-062\eclipse\eclipse.exe )
  • Click “Install/Update”
  • Quit Installer
  • Exit eclipse and Open it again

Done.

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Mayank
  • 79
  • 6
  • @Koyel Sharma: I have tested it successfully on Eclipse Jee 2019-06. The procedure might be slightly different for other versions. Please ensure that you have the lombok dependency in your project's pom.xml and you have done a Maven-Update on your project after that. Also, please ensure that you manually exit eclipse and start it again after installing lombok.jar. (It might not work on simply "Restarting" eclipse.) – Mayank May 03 '21 at 05:34
0

For me, The cause is different. My project name in settings.gradle was different from project name in eclipse.

So make sure your eclipse project name is as same as rootProject.name in settings.gradle

AzarEJ
  • 552
  • 1
  • 5
  • 16