How to Install any Java version on Raspberry Pi?

Java on Raspberry Pi, and generally on Linux, is a nightmare.
As on Windows, there are many versions, different package for users or developers. And on Linux, you add the proprietary topic as Java is now owned by Oracle
I know that many of you have issues with Java on Raspberry Pi, and I will try to help you here with this tutorial

How to install Java on Raspberry Pi?
On Raspbian Desktop with recommended software, Java is already installed by default, so most of the time you have nothing to do
With other versions, you can use the package manager : sudo apt install openjdk-11-jre, or install it from the sources available on the official website

So, the quick answer is simple, but let’s get into a little more detail now
Feel free to use the content table below if you already know the basics

Introduction about Java

As Java is not as simple as we might think, I start with a quick reminder about different concepts you need to understand before going further

What is Java?

Ok, so first point, Java is a popular programming language
You’ll find it almost everywhere, and even it’s an old school language (created in 1995), it’s still very common to use it

What developers like with Java is its portability. It’s working on about any platform without recompilation
It’s also a strong language with a huge community, so you can find help easily on Stack Overflow for example

So, even if Raspberry Pi is mainly known for Python programming, you can absolutely use it to learn Java or code something with it
You may also need Java to run some software built with it

Raspberry Pi Course
Sale: 10% off today. Take it to the next level.
I'm here to help you getting started on Raspberry Pi, and learn all the skills you need in the correct order.

Is Java open-source?

This one is a controversial point 🙂
The short answer is that Java is free and open-source

Java has been created by Sun Microsystems and licensed under the GNU GPL. So, it was crystal clear.
But in 2009, Oracle has bought Sun and so Java
Oracle main market is the companies, and it was not good news for Java developers

Currently, there are two Java versions available : Java SE and OpenJDK
OpenJDK is till available under GNU GPL, but the Oracle version is now a commercial product, free for a personal use but a paid service for a commercial use.
You can learn more here if you are interested.

You will probably need more information to understand all the story, but for now just remember that it’s complicated and you have two different products available.
On Raspberry Pi, you’ll find only have access to the OpenJDK version. There is no release or sources available for the ARM architecture for the commercial version.

Java versions

This one is easier. As with most software and programming language, there are regularly new versions available
Java was updated to a new major version almost every 6 months recently

Here is a summary of the Java version history :

VersionRelease date
Java 8March 2014
Java 9September 2017
Java 10March 2018
Java 11September 2018
Java 12March 2019
Java 13September 2019
Java 14March 2020

As always with Debian / Raspbian, recent versions are not available in the repository
Currently, Raspbian Buster includes OpenJDK11 (and a few older versions)

You should also understand that developers are not following the same rhythm
So, even if you install Java 14 now on your Raspberry Pi, some programs may not work with it, or not be optimized for this version

Most of the time the version from the Raspbian repository will be perfect with 99% of your software
And if you have an issue with something, you can check the editor recommendations to see which one you need
Sometime you will need to downgrade Java to use a specific version

Java packages

We are almost done with the theory about Java
One last thing I want to clarify is the “JDK” thing
Java developers use initials everywhere and it’s not always easy to understand as a beginner

Here is a list of initials you can find in the “Java world”:

  • JRE: Java Runtime Environment
    It’s the only thing you need if you are not a developer. It allows you to run Java software on your device
  • JDK: Java Developer Kit
    As the name suggests, it’s required for developers
    It includes the compiler, launcher and other required tools
  • JVM: Java Virtual Machine
    It’s a part of JRE, but you can also download it separately.
    It provides a runtime environment to drive Java applications

So, basically, you need to install JRE to only run Java applications, or JDK if you want to create them

Java installation on Raspberry Pi

Now that you understand all the concepts, we can move to the installation part
I will show you how to install Java with the package manager or from the website
Most of the time the package manager will be perfect, but if you need a specific version, you can check the last part

Use the package manager

During writing, the following versions are available in the Raspbian respitory :

  • openjdk-8-jre and openjdk-8-jdk
  • openjdk-9-jre andopenjdk-9-jdk
  • openjdk-10-jre andopenjdk-10-jdk
  • openjdk-11-jre andopenjdk-11-jdk

If any of them is OK for you, follow the next steps

Raspbian Desktop

As I wrote in introduction, the full version of Raspbian Desktop has already the latest Java version installed (version 11)
If you are on Raspbian Desktop “basic” or if you want to use another version instead, follow these steps:

  • In the main menu, go to Preferences > Add / Remove Software
  • Then use the search engine to find the package to install
    As you will get many answers for search like “java” or “openjdk”, look directly for the list I gave you previously
    So for example, enter “openjdk-11-jdk” in the search engine
  • Then check the corresponding package in the results
  • Click “Apply” to install it
  • Enter your password to confirm
  • And then Ok to exit

If it doesn’t work, try to update the packages lists:
Options > Refresh packages lists
This tool doesn’t display any error if the package is unavailable :/

After a few minutes, Java is installed and ready to use
You can do a quick check to verify that everything is OK by starting a terminal and typing:
java -version

And you can also use Geany or any other IDE to compile & run your first program 🙂

Raspbian Lite

On Raspbian Lite, Java is not available by default, so you can install directly the version you need

  • Start by updating the repository information to avoid any error in the installation:
    sudo apt update
  • Then install the needed package
    For example, if you want the Java 11 JRE :
    sudo apt install openjdk-11-jre
    Raspbian needs to install many dependencies (119 in my case!)
  • Confirm with “Y”

After a few minute Java is installed and ready to use
You can get the exact version and check that everything work with:
java -version

Then you can run any program with “java -jar”
For example, if your goal is to run a Minecraft Server:
java -jar spigot-xx.jar

Master your Raspberry Pi in 30 days
Sale: 25% off today. Download the eBook.
Uncover the secrets of the Raspberry Pi in a 30 days challenge.

Install another version

If you want to install another version, not available in the repository, you need to download it from the OpenJDK website
On the website, there are some Linux packages available, but there are not working on Raspberry Pi
So, your only option is to find the sources files for the version you need

I prefer to warn you directly, you’ll probably need at least one hour to try this, and there is no guarantee to succeed, so I hope you have an excellent reason to try it 🙂

Links & download

  • OpenJDK
    • OpenJDK builds for all versions are available here:
      Choose the version you want and download the corresponding file (the page layout is not always the same)
      For example, with JDK version 12 :
    • Another way is to go directly to the source code available here:
      Then you can choose a version and download the zip file from the left menu, or clone it on your Raspberry Pi
  • Oracle
    • Oracle sources seems to be only available for x64 architectures, so it probably doesn’t work on Raspberry Pi
      If I have missed something, let me know in the comments, so I could add the information here


Here is how to compile Java from the sources to get a newer or older version:

  • Extract the files from the archive
  • Install the required packages if needed:
    sudo apt install autoconf build-essential libcups2-dev libx11-dev libasound2-dev libxext-dev libfontconfig1-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev zip
  • Install the most recent JDK version available (if not already installed):
    sudo apt install openjdk-11-jdk
    Installing JDK 14 is not possible directly on Raspbian Buster
    Except if you are repeating the same thing for each missing version :/
  • Then start the configuration step:
    cd openjdk
    bash configure

    If you have any error, most of the time it will ask you to install a missing package
    Do it and start again
    But I have listed previously everything it asks me to add, so I hope you’ll not get too many errors 🙂
  • Finally, it’s a success for me, everything is ok:
  • You can now build it with:
  • And 20 minutes later get your binaries in the subfolder build/linux-arm-server-release/jdk/bin
    You can now use the java to run any code with this specific version
    ./build/linux-arm-server-release/jdk/bin/java – version

Update Java to another version on Raspberry Pi

Remove & install

You may have this notification on Windows where Java asks for an update regularly, but there is no direct way to update Java on Raspberry Pi

The easiest solution is to uninstall your current version and install the latest available
So, on Raspbian Desktop, uncheck the box in Add / Remove software and check the one you want to install

On Raspbian Lite, you can use apt to do the same thing, for example:
sudo apt remove openjdk-9-jdk
sudo apt install openjdk-11-jdk

And finally, if you installed your version from sources, remember that the previous JDK version is needed to build a new one
So don’t remove the current one

Keeping several versions

You can keep both if you want, but if it’s not mandatory it may be more of a problem than anything (for example, some software might continue to use the older version)

On Raspbian Desktop there is a great tool to switch easily between versions: G Alternatives
You can find it in the Add / remove software tool, look for “galternatives” in the search engine

Once installed, it’s available in the main menu > Preferences > Alternatives Configurator
It looks like this :

Then you can check the version you want to use and this version will be used by default by all the applications


That’s it, you now know many things about Java and especially how to install and update it on Raspberry Pi

If you had issues with Java, I hope this post was useful for you

Patrick Fromaget

I'm the lead author and owner of My goal is to help you with your Raspberry Pi problems using detailed guides and tutorials. In real life, I'm a Linux system administrator with a web developer experience.

One thought on “How to Install any Java version on Raspberry Pi?

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts

Master your Raspberry Pi - eBook Sale