Install the Latest Eclipse Java IDE on Debian 8 and Ubuntu 16.04 Linux

Introduction

Eclipse is a powerful and feature-rich IDE for Java developers, but the versions packaged with Debian and Ubuntu lag far behind the latest releases. In fact, the version shipping with Ubuntu 16.04 was released in 2012 and was discontinued quite some time ago.

Despite the fact that both Ubuntu and Debian don’t package and ship new versions of it anymore, Eclipse is still easily available to users of both distributions. You just have to go about getting it a different way, and the Eclipse developers have a great solution for this.

Getting Java 8

Since Eclipse is primarily a Java IDE(You can use it with other languages), you’re probably going to want to install Java 8 on your system to be able to develop applications. The good news is; Java 8 is available for both Ubuntu and Debian.

Debian Jessie

Java 8 was not made available to Debian users when Jessie was first launched, but it is available through the jessie-backports repository. So, the first step in getting Java 8 installed is to enable that repository.

Open up /etc/apt/sources.list in your favorite text editor as root and add the following line.

# Backports repository
deb http://httpredir.debian.org/debian jessie-backports main

Feel free to add contrib and non-free if you’d like too.

Now, update apt with the new repository.

# apt-get update

After apt finishes updating, you can install the packages from jessie-backports.

# apt-get -t jessie-backports install openjdk-8-jre openjdk-8-jdk


Ubuntu 16.04

For users of Ubuntu 16.04, getting Java 8 installed is very easy. It’s available right in the default Ubuntu repositories. Just use apt to install the packages.

$ sudo apt-get install openjdk-8-jre openjdk-8-jdk

Downloading Eclipse

The Eclipse developers provide two ways to install Eclipse. One of them involves downloading and using a custom installer program that can select different versions of Eclipse and IDEs for different languages, like C++ and PHP. Since this guide is focused on Java, it is going to cover the more direct route.

Eclipse is provided as a pre-compiled binary in a tarball. This is the simplest way to distribute it in a way that will work for every Linux distribution.

To get the tarball, navigate to the download page on the Eclipse website.

https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/neon/1a/eclipse-java-neon-1a-linux-gtk-x86_64.tar.gz

Once there, click the “Download” button. You can either use your graphical archive manage and extract it to the directory of your choosing or save it and use tar. This guide is going to use tar.

Now, cd into the directory where you want Eclipse “installed.” Eclipse is more-or-less self-contained in its folder, so it’s not really installed on the system. It’s just a binary that resides in your home directory.

Once there, use tar to extract the archive into that directory.

$ cd ~
$ tar xpf Downloads/eclipse-java-neon-1a-linux-gtk-x86_64.tar.gz

The resulting folder will simply be called “eclipse.”



Running Eclipse

Now, a functional installation of Eclipse exists on your system at ~/eclipse. You can either launch it graphically from your file browser by clicking on the item in the folder called, “eclipse,” or you can launch it from the command line.

$ cd eclipse
$ ./eclipse

When you run it, Eclipse will prompt you to set up a workspace for yourself. This is the folder that will contain all of your projects and their associated files.

Creating A Launch Icon

It may be better than nothing, but launching Eclipse this way is far from ideal. Since this is Linux, the solution is quite simple; create a .desktop file for it.

To create the desktop file, cd into .local/share/applications in your home directory.

$ cd ~/.local/share/applications

Create a new file using your favorite text editor called eclipse.desktop. You can customize the file how you like, but if you’re not sure what to add, copy the example below.

[Desktop Entry]
Type=Application
Name=Eclipse
Icon=/home/YOURUSER/eclipse/icon.xpm
Path=/home/YOURUSER/eclipse
Exec=/home/YOURUSER/eclipse/eclipse
StartupNotify=false
StartupWMClass=Eclipse

Now, Eclipse should be available through your desktop environment’s menu. If it’s not there, logout and log back in. It’s also important to use absolute paths like the ones specified. Relative paths or variables like $HOME won’t work.

Conclusion

Using this method, you can install and use the latest versions of Eclipse with up-to-date versions of Java on Debian and Ubuntu. To keep your Eclipse install current, use the built-in update functionality in the program by navigating to Help > Check for Updates.