Installing Lombok

October 02, 2015

Lombok, Indonesia

Lombok is now used in Spring Cloud and though many Java developers have avoided it, the idea of dropping boilerplate appeals to us all. Now that we have lambdas in JDK 8 now is a good time to take the extra step to reduce the fat even further.

There’s seems to be a lot problems with the install, so we’ve put together a guide from our install experience for Eclipse Mars or Spring Tool Suite.

Close Eclipse and Spring Tool Suite if they are running.

Download Lombok from their website. Then you should run the lombok.jar:

java -jar lombok.jar

You’ll be presented with a small GUI which asks you to select your Eclipse installs. If you’ve installed to a default place it might find them automatically, but assuming not then you should Browse and select the ini file - that is eclipse.ini or STS.ini.

The Lombok installer will add a few lines to the ini file:

openFile
-vmargs
-Dosgi.requiredJavaVersion=1.7
-Xms40m
-XX:MaxPermSize=256m
-Xverify:none
-Xmx1200m
-javaagent:/path/to/sts-bundle/sts-3.7.1.RELEASE/lombok.jar

We use Java 8, so have changed the line above to read -Dosgi.requiredJavaVersion=1.8. Save the file.

Normally you run Eclipse/STS through the GUI but for once we need to run through the command line. Assuming that you have these installed on the PATH (if not, you should navigate to the install directory and run from there) then you can run :

# If you run Eclipse
eclipse -clean

# If you run STS
STS -clean

On Ubuntu running from the command line seems to work find but not from the launcher (ie from Unity menu). It the the Unity launcher script just goes straight to the Jar file and it also overrides some settings. See the Exec line in the file ~/.local/share/applications/spring-tool-suite.desktop (or eclipse.desktop):

[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Name=Spring - Spring Tool Suite
Icon=spring_tool_suite.png
Path=/path/to/Applications/sts-bundle/sts-3.7.1.RELEASE
Exec=/usr/bin/java -D...lots of defines here... -jar /path/tp/sts-bundle/sts-3.7.1.RELEASE//plugins/org.eclipse.equinox.launcher_1.3.100.v2015$
StartupNotify=false
StartupWMClass=Spring Tool Suite
OnlyShowIn=Unity;
X-UnityGenerated=true

We change the Exec line to:

Exec=/path/to/Applications/sts-bundle/sts-3.7.1.RELEASE/STS

Finally when you get into eclipse run Project > Clean > All projects and then Maven Update all projects.

This comprehensive/belt and braces worked for us, but seems to work!

Credit: Photo by Atilla Taskiran on Unsplash

Work with us

Have a project or an idea? We'd love to talk with you and see if we can help.

GET IN TOUCH
.

3 Strand Court

Bath Road

Cheltenham

Gloucestershire

GL53 7LW

© Committed