Say Good-Bye To Boilerplate Code With Lombok: Part 1-Installation | CodersTea
Home Java Say Good-Bye to Boilerplate Code with Lombok: Part 1-Installation

Say Good-Bye to Boilerplate Code with Lombok: Part 1-Installation

by Imran Shaikh
Published: Last Updated on 581 views
Project Lombok

Hey! Tea lovers! Before talking about Lombok, what are the things that irritate us Java Developer the most? Well yes, hearing “Java is dying” from a Python developer is irritating but it is the second thing. The first one is the boilerplate code. We write it almost every time. Setters and getters, constructor, toString, and many others for simple POJO class. Of course, IDE can generate this code for you but again, your simple POJO class then becomes redundant. And only things that matter in the POJO are the fields, so why not write fields only and let the compiler handles the rest of the things. And that’s where Project Lombok comes into the picture.

You can follow me on social media via @coderstea on TwitterLinkedinFacebook, or Instagram. We also share high-quality videos about programming on our Youtube channel. You can also publish your post on CodersTea, just share your thought on Contact Us or let us know in the comments.

Let us see how Lombok makes your code less cluttered and readable. So, prepare your cup of tea to sip and code with CodersTea

What is Project Lombok

The official page says this:

Project Lombok is a java library that automatically plugs into your editor and builds tools, spicing up your java.
Never write another getter or equals method again, with one annotation your class has a fully-featured builder, Automate your logging variables, and much more.

In short, it generates code for most of the common things, that too in compile time. It generates not only setters or getters but also constructors, log variables, builders, util class, etc.

Install Lombok

As it’s a library, you need to download it from Project Lombok. Version as of now is 1.18.12. This library can be used via various ways such as JDK compiler or javac, IDEs such as IntelliJ, Eclipse, and NetBeans, build tools like Maven, Gradle, etc, and you can also use it in Android.

For this post, I will show you IDE integration with both IntelliJ and Eclipse. Once we set up the library, we will move on the how to use it with our code.


Once you download the Lombok jar, run the jar. you can double click and run it or run via command with

java -jar lombok.jar

It will open up a window to install it. But make sure Eclipse is closed otherwise it may not take effect. You will see the following window and a list of eclipses on your system. Select the one you want to integrate with and click on Install/Update button.

lombok installer
Eclipse installer from

If you are not seeing the list, then click on the Specify Location and go to your Eclipse IDE path. In my case its “D:\Runnable\eclipse-ide\2020-03\eclipse”. click eclipse.exe and ok.

lombok eclipse path
Install via specifying eclipse location.

Then, click the quit installer. Now, you will see the lomok.jar in the eclipse folder as well. You can verify by going Help > About Eclipse IDE. You will see the following in the last line.

lomboko eclipse installation complete
Verify installation

IntelliJ IDEA

Well, it’s very simple. You just have to install the Lombok plugin from the marketplace.

  1. File> Settings or click Ctrl + Alt + S.
  2. Plugins > Marketplace tab
  3. Search for Lombok
  4. Install the plugin by Michail Plushnikov
  5. Restart the IDE
lombok intellij installation
Lombok Installation in IntelliJ IDEA

Since it works on compile-time and needs annotations, you might want to on the annotation processor. In the latest version, it shows a popup to start it after you install Lombok. If not, try doing the following.

  1. File> Settings or click Ctrl + Alt + S.
  2. Build, Execution, Deployment > Annotation Processors
  3. Check Enable annotation processing and then click apply.
annotaion processing intellijIdea
IntelliJ IDEA annotation processing

Add Lombok Dependency

Now that we installed it in our IDE we need to use it in our code. But to do that you have to add the dependency of the Lombok library into the code. You can do it manually or via maven. Here is the Maven dependency:

    <!-- use the latest stable version.-->

For Gradle users, you can do so by adding the following,

repositories {
dependencies {
	compileOnly 'org.projectlombok:lombok:1.18.12'
	annotationProcessor 'org.projectlombok:lombok:1.18.12'
	testCompileOnly 'org.projectlombok:lombok:1.18.12'
	testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'

To be Continued…

The installation and usage explanation made the post a bit long. So I decided to divide the post into two parts. This part was about what is Lombok and how to install it. In the second part, we will see how to incorporate the Lombok into our code. Please continue your reading with “Say Good-Bye to Boilerplate Code with Lombok: Part 2-The Code“.

You can see more posts like this on CodersTea. Or search by categories such as Java, Spring, and Best Practices.

See you in the next post. HAKUNA MATATA!!!

Notify of
1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More