25

I downloaded lombok.jar (lombok-1.16.14.jar) put it into my Downloads. Then I clicked on this jar, the execution correctly identifies the Eclipse instances on my MacOS and then I selected the instance I want. Lombok is also specified in the pom.xml org.projectlombok lombok 1.16.14 provided

In eclipse.ini I got the addition: -javaagent:../Eclipse/lombok.jar

lombok.jar was added to the same directory as eclise.ini /Applications/Eclipse.app/Contents/Eclipse

I am still getting setter/getter errors in Eclipse Problems despite that my mvn build works fine.

The code for a User:

@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@EntityListeners(UserListener.class)
public class User implements Serializable, UserDetails {
...

The error:

The method getRole() is undefined for the type User 
8
  • Add lombok as dependency?
    – jklee
    Feb 24, 2017 at 18:45
  • It is already there: <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency>
    – Alex
    Mar 12, 2017 at 12:02
  • User has getRole method for sure?
    – minigeek
    Mar 12, 2017 at 12:24
  • I see you're using an annotation @EntityListeners that's not from Lombok, maybe is there some conflict between those annotation processors? Lombok changed something to be able to be compatible with some other processors in last version projectlombok.org/changelog.html Mar 15, 2017 at 13:57
  • restart the eclipse and build the project from eclipse. sometimes eclipse fails to sync its project tree with the actual project Mar 17, 2017 at 11:57

19 Answers 19

50
+25

Since you have already added the .jar to your lib folder, then go to the lib and execute java -jar lombok-1.16.4.jar, you'll see a wizard, specify the location of your eclipse.ini, after you are done with this your eclipse.ini file should look like this:

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

For me this just worked fine but I found in other answers that:

  • You should not just "restart" Eclipse, go to File -> Exit and then open it again. taken from here
  • Don't forget to do a mvn clean just to make sure that you recompiled your classes. taken from here
  • After all this you should also right-click on your project, then Maven -> Update Project taken from here
6
  • 2
    I see -javaagent:../Eclipse/lombok.jar after running lombok.jar. But i do not see -Xbootclasspath/a:lombok.jar.
    – Alex
    Mar 18, 2017 at 0:41
  • @AlexNarinsky Please try adding the line manually and let me know
    – imTachu
    Mar 19, 2017 at 11:31
  • 1
    did not help either
    – Alex
    Mar 21, 2017 at 10:38
  • 1
    @AlexNarinsky maybe you have a similar problem like mentioned in my answer (i.e. that just the desktop-link does not respect the settings defined in eclipse.ini). You could check that by simply starting eclipse from the command line using the eclipse executable next to the eclipse.ini. If its working, you see something like "Lombok ... is installed" in "Help"->"About Eclipse".
    – mam10eks
    Jun 5, 2017 at 8:57
  • 2
    perfect! the "not just restart eclipse" hint solved my problem.
    – derwiwie
    Apr 5, 2018 at 7:36
13

There is a manual way to install lombok under eclipse, I do not checked it, but it maybe helps you -

  1. copy lombok.jar to where your eclipse folder where is the eclipse.ini

  2. open eclipse.ini,put at end the below two lines below and save it

    -Xbootclasspath/a:lombok.jar
    -javaagent:lombok.jar
    
  3. restart eclipse.

2
  • manual way to install lombok under eclipse: stackoverflow.com/a/46034044/2987755
    – dkb
    Aug 31, 2018 at 10:57
  • year 2020, lombok does not need manual configuration for eclipse, except, manually press the button clean project!!!
    – Tiina
    Jan 6, 2020 at 4:33
6

I had the problem, that the link, which I used to start eclipse, didnt respect the eclipse.ini file.

My environment is:

IDE: Version: Neon.0 Release (4.6.0)
OS: Ubuntu 16.04.2 LTS

The installation routine java -jar lombok-1.16.16.jar works quite well. I.e. it adds the reasonable line -javaagent:<ABSOLUTE_PATH_TO_ECLIPSE_INSTALLATION>/lombok.jar to the eclipse.ini.

But if I start eclipse by using my desktop-shortcut, it starts without lombok (checked by looking at "Help"->"About Eclipse"). If I start eclipse by executing the executable eclipse next to the eclipse.ini file, lombok launches like a charm.

Hence I checked my desktop shortcut (e.g. ~/.local/share/applications/eclipse.desktop) and indeed, it started eclipse without reflecting the eclipse.ini. Instead it uses something like /usr/bin/java -jar org.eclipse.equinox.launcher.jar ... to start eclipse.

So the solution was to replace the old Exec line in the desktop shortcut by:

Exec=/opt/eclipse/neon/eclipse

where /opt/eclipse/neon/ is the place where I have installed eclipse.

0
5

Antoniolazaro has given a solution for Eclipse Neon issue on MacOS

When I put the complete path, it works on Mac Os.

-javaagent:/Applications/Eclipse.app/Contents/Eclipse/lombok.jar

Resource Link:

  1. https://github.com/rzwitserloot/lombok/issues/1173

And the lombok project owner rzwitserloot has given 3 suggestions for checking

  1. Can you give us the complete path, from root, of your eclipse install? Starting with 1.16.14, the installer should still find eclipse even with the funky paths that the OOM installer comes up with. I have no idea why the installer isn't finding your eclipse automatically, here. I can't reproduce this on my mac.
  2. The lombok uninstaller has the same 'find eclipses' capability as the installer. Mac doesn't have a registry and we aren't going to dump a bunch of crud in your homedir just to keep track of where we installed your lombok; we like it that way: No cruft. So, that part (that the uninstaller can't find a custom-install location and requires you to again specify it) is not a bug.
  3. You still have to add lombok.jar to your project as a dependency same as any other third party dependency (something like guava, for example). It's not clear from your problem description if you actually did that.

Resource Link:

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

2
  • Please, read the updated description. Specifying the full path did not help
    – Alex
    Mar 20, 2017 at 18:30
  • @AlexNarinsky Thanks for sharing
    – SkyWalker
    Mar 20, 2017 at 18:32
3

Even after following the below steps(try the steps given below first) , if it doesn't works, one issue can be that you are using the eclipse from the desktop , not from the folder where eclipse is installed. Running eclipse from the desktop sometimes is unable to load the .ini file, hence lombok won't run. So, try running the eclipse from the folder where you have installed it.

Steps: 1. Give the lombok dependency in the pom and build it.

  1. The lombok.jar is usually downloaded in the folder .m2/repository/org/projectlombok/lombok/1.x.y
  2. Install the jar in the folder "java -jar lombok-1.x.y.jar"
  3. Then it will ask you to select the IDE. Browse to the eclipse installation folder and select eclipse from there.
  4. Now your eclipse installation folder, should contain the lombok.jar and eclipse.ini should contain the line -javaagent: /lombok.jar

  5. Run the eclipse from the installation folder. Clean and rebuild the project. It should work now!

1
  • This is actually one of the BEST replies - thank you! See my explanation below.
    – paulsm4
    Oct 27, 2018 at 20:38
1

try @Data annotation for the class.

public @Data class user{
 \\do stuff
 }
1
  • Did not help, i am also getting "Data cannot be resolved to a type ". I also added: import lombok.Data;
    – Alex
    Mar 18, 2017 at 0:52
1

For me, downloading the latest Eclipse Neon, i.e. Neon 3, fixed the problem

1

My environment is:

IDE: Version: Neon.3 Release (4.6.3)
OS: Ubuntu 16.4

It works for me when i do this steps below:

1. copy `lombok.jar` to where your eclipse folder where is the `eclipse.ini` ;
2. open `eclipse.ini`,put at end the two lines below with full lombok path and save it:
    -Xbootclasspath/a:/DEV/Tools/IDE/eclipse/jee-neon/lombok.jar
    -javaagent:/DEV/Tools/IDE/eclipse/jee-neon/lombok.jar
3. restart  `eclipse` in command line (when i try run with exist link in launcher it's not work)
4. rebuild your projects
1
  • 1
    Hello @rafambbr, since you mentioned that using the existing link to start eclipse didnt start lombok, you may check your Exec command that is used by the desktop-link.
    – mam10eks
    Jun 5, 2017 at 8:51
0

As far as I am concerned, I use a "Chocolatey" distribution of Eclipse on Windows.

It does not change much. But for those of you who are not admin of their desktop, it might be a hassle, because Chocolatey installs softwares in C:\ProgramData\... which is an "admin" directory.

In other words, you may need to modify your shortcut's property "start in" which will not be possible unless you are admin of your desktop.

The trick that worked for me here was to create a new shortcut, which has the correct "start in" property to start eclipse in the directory where the eclipse.ini is...

Then recompile using eclipse, then work on your project a bit until eclipse realizes that lombok was installed...

Cheers

0

After installing lombok, you need to copy lombok.jar into your project or add dependency in maven configuration xml file

0
0

exit the eclipse and then go to the eclipse directory and open eclipse.ini and add -clean on a top and rerun the eclipse. hope your problem is solved.

0

To elaborate on the above replies:

  • PROBLEM:

    In my scenario:

    1. I installed SpringBoot STS under Eclipse Photon,
    2. I created aSpring Boot/Gradle build project, and I got the "undefined method" error using Lombok @Data.
    3. Environment: Ubuntu Linux 18.04.
  • SOLUTION:

    1. cd ~/.gradle/cache/.../lombok/...;
    2. java -jar lombok-1.16.22.jar
  • NOTE:

    java -jar lombok*.jar brings up a GUI that

    1. Allows you to select which Eclipse install to update.
    2. Updates eclipse.ini AND...
    3. Copies lombok-xyz.jar into the Eclipse install folder, as lombok.jar.
0

Eventhough there are already a lot of answers here none of the given answers solved my problem, so I'll add my information here as well in case it might help someone:

My setup is:
Win10 Home,
Eclipse Version: Oxygen.3a Release (4.7.3a),
Eclipse Build id: 20180405-1200,
  1. Add lombok to my pom.xml
  2. mvn clean install
  3. close eclipse
  4. navigate to my .m2 folder .m2\repository\org\projectlombok\lombok\1.18.6>
  5. run: java -jar .\lombok-1.18.6.jar (or whatever version you have
  6. Install lombok

Now it's getting intresting. The installation added the following to my eclipse.ini:

-javaagent:lombok.jar

How ever it placed them at the bottom of my .ini file. So it looked liked this.

--launcher.appendVmargs
-vmargs
-...
--add-modules=ALL-SYSTEM
-javaagent:lombok.jar

I assumed that -javaagent:lombok.jar belongs under -vmargsso I put it at the bottom of --launcher.appendVmargs. That didn't work either though. But when I put -javaagent:lombok.jarright below vmargs it works. Ultimately my eclipse.ini looks like this:

--launcher.appendVmargs
-vmargs
-javaagent:lombok.jar # lombok works for me if this is here
-Declipse.p2.max.threads=10
- Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest
-Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/
-Dosgi.requiredJavaVersion=1.8
[email protected]/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
#-javaagent:lombok.jar | lombok doesn't work for me if its placed here.
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m

Not sure why this issue orcurrs but maybe it helps you. If you are under macOS remember to add -Xbootclasspath/a:lombok.jalike other answers in this thread suggest.

0

I have faced this issue recently and all the above solutions mentioned by the above users didn't work. The problem I have was there are special symbols like '$' in path(This can be found in last line of eclipse.ini file) to eclipse. Due to the same reason lombok cannot identify the file and append the necessary two lines in eclipse.ini file. Removing the special characters like '-' , '$', '_' in my eclipse path fixed mu problem

0

For, after installing lombok like mentioned above I had to do right click on your project folder -> Run as -> Maven clean. Ne the .jar is deteced and properly used

0
  1. Copy and paste the lombok jar into the eclipse installation folder.
  2. Run the command "java -jar lombok-.jar".
  3. A GUI opens.
  4. Check the IDE listed in the installer.
  5. This entry should be available in the eclipse.ini file "-javaagent:<>".
  6. Restart Eclipse to find the changes which starts listing the associated getters, setters in your java file.
0

Simply add to eclipse.ini file this statement (or check if you have):

-Xbootclasspath/a:lombok.jar

-javaagent:lombok.jar

Attention please, usually you have only:

-javaagent:lombok.jar

Obviously restart your eclipse

0

For Eclipse neon on Mac (High Sierra) :

  • Use lombok version 1.16.14 or above.

  • Installer launches by running (double clicking) lombok-1.16.14.jar file itself. It should detect installed versions.

  • On the Mac, it detects Eclipse.app only from Applications directory. If not, you can tell the jar where to find it in the popup dialog. Note that you should point it to eclipse.ini file (Eclipse.app -> Show app contents -> eclipse -> eclipse.ini)

  • Lower versions of lombok do not work on High Sierra. They don't detect installed eclipse instances.

  • Finally remember to restart eclipse (via File -> exit) and run maven update project.

0

I might be late to reply here but for future references adding this answer,

  1. Please don't use Lombok v1.18.14 as it will crash eclipse. It is mentioned in changelogs. Use next version v1.18.16.
  2. Simple way to setup lombok to eclipse is mentioned in this answer https://stackoverflow.com/a/69332138/3637115

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.