I can't install lombok in Spring Tool Suite 4 ide on Ubuntu

446 Views Asked by At

I'm trying to install lombok in the Spring Tool Suite 4 ide which is in the /opt folder on Ubuntu. The command: java -jar lombok.jar does not work because the opt folder requires privileges. enter image description here

I tried using the command suggested by the installation software: sudo java -jar lombok.jar I get the result:

sudo: java: command not found

Note: I have the SDKMAN software development kit manager installed to manage java versions.

1

There are 1 best solutions below

6
On BEST ANSWER

Because root does not have sdkman install. root can not get java.

You can do this:

sudo su -

mkdir -p /usr/lib/jvm

cd /usr/lib/jvm

ln -s /home/YourUserName/.sdkman/candidates/java/current jdk

nano /root/.bashrc

# ADD This 
export JAVA_HOME=/usr/lib/jvm/jdk
export PATH=/usr/lib/jvm/jdk/bin:$PATH

# Ctrl + O save 
# Ctrl + X exit nano

exit

UPDATE:

Add JDK Path to sudoers config:

Run Command : sudo nano /etc/sudoers

find Defaults secure_path="/usr/local/sb..."

append :/usr/lib/jvm/jdk/bin at end of this line

it will like Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/usr/lib/jvm/jdk/bin"

save and exit nano.

Test: sudo java -version

Then you can run sudo java -jar lombok.jar