Saturday, June 20, 2020

The Best Way to Install Java JDK and Eclipse IDE on Linux Ubuntu Desktop

In order to install Java on your ubuntu, I assume you are working from home directory cd ~ or cd $HOME which in my case is "/home/omar" or use sudo su - to switch to root user and avoid typing sudo everytime you need root privilege. To start, open a new terminal Ctrl+Alt+T and run the following command:
sudo apt update && sudo apt install openjdk-11-jdk-headless -y
view raw sh hosted with ❤ by GitHub
then run the command below to find JDK installation directory:
update-alternatives --config java
view raw sh hosted with ❤ by GitHub
Afterward, open the startup script file vim ~/.bashrc and add the following lines in the bottom:
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
view raw .bashrc hosted with ❤ by GitHub
then run the following command to activate the new path settings immediately:
source ~/.bashrc
view raw sh hosted with ❤ by GitHub
Now that you have java installed, go to Eclipse IDE download page: https://www.eclipse.org/downloads/download.php?file=/oomph/epp/2020-06/R/eclipse-inst-linux64.tar.gz and download the Eclipse installer archive. Once downloaded, extract the archive content by running the command below:
sudo tar -xvzf eclipse-inst-linux64.tar.gz
view raw sh hosted with ❤ by GitHub
After extracting the installer, open vim ~/eclipse-installer/eclipse-inst.ini file and append the following configuration:
-vm
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
view raw ini hosted with ❤ by GitHub
then launch the installer: cd ~/eclipse-installer/ && ./eclipse-inst and choose Eclipse IDE for Enterprise Java Developers. Once you have Eclipse installed, open its configuration file vim ~/eclipse/jee-2020-06/eclipse/eclipse.ini and add the following:
-vm
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
view raw ini hosted with ❤ by GitHub
now, create a shortcut for eclipse by creating a new file vim ~/eclipse.desktop and inserting the following content into it:
[Desktop Entry]
Name=Eclipse
Type=Application
Exec=/home/omar/eclipse/jee-2020-06/eclipse/eclipse
Terminal=false
Icon=/home/omar/eclipse/jee-2020-06/eclipse/icon.xpm
Comment=Integrated Development Environment
NoDisplay=false
Categories=Development;IDE;
Name[en]=Eclipse
Name[en_US]=Eclipse
view raw eclipse.desktop hosted with ❤ by GitHub
then install the shortcut:
sudo desktop-file-install eclipse.desktop
view raw sh hosted with ❤ by GitHub
That's it, congratulation! from now on you can find your Eclipse among Ubuntu applications.

Bonus: 

 You can also install Lombok utility within eclipse; all you have to do is go to Lombok download page: https://projectlombok.org/download and download the jar. Once the jar downloaded, launch it by running java -jar lombok.jar and specify the eclipse.ini file location /home/omar/eclipse/jee-2020-06/eclipse/eclipse.ini

No comments:

Post a Comment