DEV Community


Posted on

Ubuntu 18.04 install Java and Eclipse IDE


  1. Download an JDK gz file.

  2. Download Eclipse IDE installer gz file.
    you can select an mirror site for downloading it.

Config JDK

Extract and Install Java

tar -xvf ~/Downloads/jdk1.8.0_201.tar.gz

Create an folder to store it.

sudo mkdir /usr/lib/jvm/jdk1.8.0_201

Move extracted package to the directory.

sudo mv jdk1.8.0_201*/* /usr/lib/jvm/jdk1.8.0_201/

Run the commands below to configure java.

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_201//bin/java" 1010 
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_201//bin/javac" 1010 
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.8.0_201//bin/javaws" 1010
Enter fullscreen mode Exit fullscreen mode

Create Java Environment Variables.

New an file.
sudo vim /etc/profile.d/

Copy this lines to

export J2SDKDIR=/usr/lib/jvm/jdk1.8.0_201
export J2REDIR=/usr/lib/jvm/jdk1.8.0_201/jre
export PATH=$PATH:/usr/lib/jvm/jdk1.8.0_201/bin:/usr/lib/jvm/jdk1.8.0_201/db/bin:/usr/lib/jvm/jdk1.8.0_201/jre/bin
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_201
export DERBY_HOME=/usr/lib/jvm/jdk1.8.0_201/db
Enter fullscreen mode Exit fullscreen mode

Make it effective.
source /etc/profile.d/

Test if successful.
Run the commandjava -version, it will show messages like this

java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
Enter fullscreen mode Exit fullscreen mode

if it, Congratulations!

Install Eclipse

Extract eclipse installer gz file, then just run the eclipse-inst executable file.
or run the command on eclipse installer directiry

Next, it is some easy steps!

Add an icon on application lancher

Step1: change current directiry to /usr/share/applicaitons

cd /usr/share/applicaitons

Step2: new a Java.desktop file.

Input the lines:

[Desktop Entry]
Name=Java #name it
Exec=/path/eclipse #your path
Icon=/path/icon.xpm #your path
Enter fullscreen mode Exit fullscreen mode

Step3: Give it execution permission.

Run the command:
sudo chmod +x Java.desktop


This is my first post, if there are any errors, please correct me:)

Top comments (0)