How to fix Eclipse with OpenJDK 9

The Eclipse snap package from the default Ubuntu repositories is perfect for Java programming because it is bundled with a Java development environment. To install it open the terminal and type:

sudo snap install eclipse --classic  

This command will install the latest Photon Release 4.8 version of Eclipse IDE for Java Developers which was updated 8 days ago. Eclipse changed its codename policy so that Eclipse releases from September 2018 and onward are named after the year and month of the release date, for example Eclipse 2020-06. This naming scheme also applies to the eclipse snap package.

Photon JDT supports Java 9 completely:

  • The Eclipse compiler for Java (ECJ) implements all the new Java 9 language enhancements.
  • Updated significant features to support Java Modules, such as compiler, search and many editor features.

Though I always prefer packages from the Ubuntu distro, I make an exception for Eclipse because it (a) is trivial to install, (b) must be installed as user (no root required or recommended), and (c) it manages its own updates and plugins very well - including rollbacks, etc.

The instructions below work for all Eclipse IDEs (Java, C/C++, Web, PHP, etc).

  1. Install the JDK

    sudo apt install default-jdk
    
  2. Download the latest Eclipse installer from eclipse.org. Currently this is Eclipse Photon.

  3. Unpack it in a directory of your choice

    mkdir -p ~/eclipse/installer
    tar -C ~/eclipse/installer -xzf ~/Downloads/eclipse-inst-linux64.tar.gz
    
  4. Run the installer

    cd ~/eclipse/installer
    ./eclipse-inst
    
  5. Pick your IDE and follow the prompts

When done, start your IDE with the eclipse script in the directory eclipse underneath where you installed the IDE.

To uninstall any Eclipse IDE, simply rm -r its installation directory. If you are obsessive about kruft pollution then also rm -rf ~/.eclipse.