Install Java 11 on the Raspberry Pi

Check out my new tutorial how to install Java 14 on your Raspberry Pi.

This tutorial teaches you how to run and install Java 11 on the Raspberry Pi. We will install, create a very simple “Hello World” application as well as compile that program and run in on the Raspberry Pi.

You find more information about Java here


Java is one of the most popular programming languages in the world and with some simple command it is available to you on the Raspberry Pi.


First of all I think it is always a good idea to have your Raspberry Pi up to date. You do that by running the following command in the terminal. It will update and upgrade all the programs you currently have installed on your device. It will try to update quite a few libraries and programs and you need to enter yes when upgrading.

# sudo apt-get update && apt-get upgrade

When everything is updated you want to install the Java packages. You do that by running the following command. (It will take some time, a lot of things are going to be installed.)


#  sudo apt-get install openjdk-11-jdk

When the Raspberry Pi has installed the Java packages you should be able to run ”java -version” and have the following output:


Also the java compiler should be present, try running ”javac –version” and you should have a similar printout like this:

You have now installed Java on your Raspberry Pi! But how do we run a program? Let’s create a very simple program to demonstrate this. I am using a program called nano to write a very simple application, also known as ”Hello World”.

# nano
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World");

Ctrl + X and yes, to save and exit Nano.


We have now only the source code for the program. To be able to run the program you want to compile the program and that is what the program ”javac” is for. Run the following command to compile the Hello World program.

# javac

You should now be able to see a new file called HelloWorld.class appear in the same folder as That is the compiled program for the

You can now run your program using the following command.

# java HelloWorld


And there you go, you have now installed Java 11 and your first java application is running on your Raspberry Pi. Good work!

What’s next?

Java is one of the most popular languages in the world and a lot of different frameworks exists which will make your life easier when programming Java. One of them is Spring, I suggest checkout out this tutorial to getting started with Spring Boot. You can also see this Philips Hue tutorial to get inspired!