Technohelp

Raspberry PI

Install Java Runtime on a Raspberry PI

Steps tested on a PI 3


Updated at: 2019-02-19 22:29:56 (Author: Admin)

You may find that attempting to install JAVA runtime on a Raspberry PI via the internal package manager does not work and exits with an error similar to the following one:

Error: missing `server' JVM at `/usr/lib/jvm/java-8-openjdk-armhf/jre/lib/arm/server/libjvm.so'. Please install or use the JRE or JDK that contains these missing components. E: /etc/ca-certificates/update.d/jks-keystore exited with code 1. done. Errors were encountered while processing: ca-certificates-java openjdk-8-jre-headless:armhf openjdk-8-jre:armhf E: Sub-process /usr/bin/dpkg returned an error code (1)

There is an alternative to this but, be advised, you would then have to run the compiled .jar file that you are attempting to run from the command line. Nevertheless, this is better than nothing.

Steps are as follows:


Visit the following link

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Click the download button of Java Platform (JDK) 8. Click to Accept License Agreement, download jdk-8-linux-arm-vfp-hflt.tar.gz for Linux ARM v6/v7 Hard Float ABI.

Log-in Raspberry Pi, enter the command to extract jdk-8-linux-arm-vfp-hflt.tar.gz to /opt directory.

$ sudo tar zxvf jdk-8-linux-arm-vfp-hflt.tar.gz -C /opt

Set default java and javac to the new installed jdk8.

$ sudo update-alternatives --install /usr/bin/javac javac /opt/jdk1.8.0/bin/javac 1

$ sudo update-alternatives --install /usr/bin/java java /opt/jdk1.8.0/bin/java 1

$ sudo update-alternatives --config javac

$ sudo update-alternatives --config java

After all, verify with the commands with -version option.

$ java -version

$ javac -version

After doing all this you will hopefully be able to run your java .jar file from the command line

java -jar filename.jar