How to install Java 8 on Raspbian?
How would I go about doing this? I don't see a good package when I do apt-cache search jre, they are all java 6 and 7.
I am wanting to install filebot, but to do so I apparently need to install Java 8.
Can anyone point me in the right direction? A search of the forum disregarded install and 8, and just searched for java, which returned over 6000 posts and the first few pages of results were not helpful, lol
I am wanting to install filebot, but to do so I apparently need to install Java 8.
Can anyone point me in the right direction? A search of the forum disregarded install and 8, and just searched for java, which returned over 6000 posts and the first few pages of results were not helpful, lol
- DougieLawson
- Posts: 42327
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: How to install Java 8 on Raspbian?
sudo apt-get install oracle-java8-jdk
Although on a stock Raspbian (or NOOBS) 2015-02-16 install it's already there.
Although on a stock Raspbian (or NOOBS) 2015-02-16 install it's already there.
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: How to install Java 8 on Raspbian?
Very cool, I see you are correct it was already installed, as when I tried to add it via apt-get it said it was already the most up to date version.
However, something seems to be not right.
When I try to execute the filebot.sh script from the most recent filebot portable (http://sourceforge.net/projects/filebot/), I get the following errors
Which is confusing, as the java 8 package you mention is clearly installed. Any idea what is wrong here?
However, something seems to be not right.
When I try to execute the filebot.sh script from the most recent filebot portable (http://sourceforge.net/projects/filebot/), I get the following errors
Code: Select all
Exception in thread "main" java.lang.UnsupportedClassVersionError: net/filebot/Main : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: net.filebot.Main. Program will exit.
- DougieLawson
- Posts: 42327
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
Re: How to install Java 8 on Raspbian?
Your code has thrown an exception. You'll need to read the source code to understand why it has done that.
Languages using left-hand whitespace for syntax are ridiculous
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
DMs sent on https://twitter.com/DougieLawson or LinkedIn will be answered next month.
Fake doctors - are all on my foes list.
The use of crystal balls and mind reading is prohibited.
Re: How to install Java 8 on Raspbian?
OK, here's what I did to fix this, total linux noob but essentially I had to just change the default auto choice of java and javac for the raspberry pi (one of them was still set to the jdk6).
I did so following this guide http://www.rpiblog.com/2014/03/installi ... ry-pi.html
With these commands
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java
I did so following this guide http://www.rpiblog.com/2014/03/installi ... ry-pi.html
With these commands
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java
Re: How to install Java 8 on Raspbian?
A more 'portable' way is to set the JAVA_HOME env variable to point to the appropiate version for your project.rpi25 wrote:OK, here's what I did to fix this, total linux noob but essentially I had to just change the default auto choice of java and javac for the raspberry pi (one of them was still set to the jdk6).
I did so following this guide http://www.rpiblog.com/2014/03/installi ... ry-pi.html
With these commands
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java
Re: How to install Java 8 on Raspbian?
So in this instance, where would I find the home variable to redirect? Is that in the filebot.sh script, or elsewhere?
Re: How to install Java 8 on Raspbian?
You can set it from the CLI: export JAVA_HOME=/path/to/java/version/you/wantrpi25 wrote:So in this instance, where would I find the home variable to redirect? Is that in the filebot.sh script, or elsewhere?
Re: How to install Java 8 on Raspbian?
Thanks rpi25, running these two commands was what I needed to do to fix my javac java version mismatch.rpi25 wrote:OK, here's what I did to fix this, total linux noob but essentially I had to just change the default auto choice of java and javac for the raspberry pi (one of them was still set to the jdk6).
I did so following this guide http://www.rpiblog.com/2014/03/installi ... ry-pi.html
With these commands
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java
-
- Posts: 2
- Joined: Thu Aug 06, 2015 7:41 pm
Re: How to install Java 8 on Raspbian?
After downloading the latest version from oracle you can run a script to set the alternatives.
JAVA_DIR=/usr/lib/jvm/jdk1.8.0_121
JAVA_BIN_DIR=$JAVA_DIR/bin
JAVA_JRE_LIB_DIR=$JAVA_DIR/jre/lib
JAVA_JRE_BIN_DIR=$JAVA_DIR/jre/bin
DEST_DIR=/usr/bin
ALT_LEVEL=100
for x in $JAVA_JRE_BIN_DIR $JAVA_JRE_LIB_DIR $JAVA_BIN_DIR
do
for f in `find $x -maxdepth 1 -type f -executable`
do
NAME=`basename $f`
update-alternatives --install $DEST_DIR/$NAME $NAME $x/$NAME $ALT_LEVEL
done
done
JAVA_DIR=/usr/lib/jvm/jdk1.8.0_121
JAVA_BIN_DIR=$JAVA_DIR/bin
JAVA_JRE_LIB_DIR=$JAVA_DIR/jre/lib
JAVA_JRE_BIN_DIR=$JAVA_DIR/jre/bin
DEST_DIR=/usr/bin
ALT_LEVEL=100
for x in $JAVA_JRE_BIN_DIR $JAVA_JRE_LIB_DIR $JAVA_BIN_DIR
do
for f in `find $x -maxdepth 1 -type f -executable`
do
NAME=`basename $f`
update-alternatives --install $DEST_DIR/$NAME $NAME $x/$NAME $ALT_LEVEL
done
done
Re: How to install Java 8 on Raspbian?
My Raspbian repository does not appear to contain this package. Am I missing a source or did Raspbian remove this package from the repository?
Re: How to install Java 8 on Raspbian?
It's in the RPF repo, not Raspbian
Code: Select all
pi@raspi05:~$ apt-cache policy oracle-java8-jdk
oracle-java8-jdk:
Installed: (none)
Candidate: 8u65
Version table:
8u65 0
500 http://archive.raspberrypi.org/debian/ jessie/main armhf Packages
- HawaiianPi
- Posts: 7599
- Joined: Mon Apr 08, 2013 4:53 am
- Location: Aloha, Oregon USA
Re: How to install Java 8 on Raspbian?
Yea, it's in the RPF Stretch repo as well.
HawaiianPi@CreeperPi:~ $ apt-cache policy oracle-java8-jdk
oracle-java8-jdk:
Open a terminal and do the following:The current version of Stretch will generate an errort about no dirmngr when trying to get the key. To fix that just install it (apt-get install dirmngr) then repeat the key command and continue.This will take a little while, and you'll have to agree to the Oracle terms, so pay attention.
When that is finished you'll want to remove the old Java version. If you had the default oracle-java8-jdk installed, remove it with apt-get remove oracle-java8-jdk, then you can exit the root terminal with exit[enter].
Enter java -version to check your installed version (it should be the latest).
HawaiianPi@CreeperPi:~ $ java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) Client VM (build 25.144-b01, mixed mode)
Congrats, you now have the latest Java.
HawaiianPi@CreeperPi:~ $ apt-cache policy oracle-java8-jdk
oracle-java8-jdk:
- Installed: (none)
Candidate: 8u65
Version table:- 8u65 500
500 http://archive.raspberrypi.org/debian stretch/main armhf Packages
- 8u65 500
Open a terminal and do the following:
Code: Select all
sudo su
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
Code: Select all
apt-get update
apt-get install oracle-java8-installer
When that is finished you'll want to remove the old Java version. If you had the default oracle-java8-jdk installed, remove it with apt-get remove oracle-java8-jdk, then you can exit the root terminal with exit[enter].
Enter java -version to check your installed version (it should be the latest).
HawaiianPi@CreeperPi:~ $ java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) Client VM (build 25.144-b01, mixed mode)
Congrats, you now have the latest Java.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups, and where is that annoying music coming from?
lots of pop-ups, and where is that annoying music coming from?
Re: How to install Java 8 on Raspbian?
@HawaiianPi Thanks. Your post worked great for me.
Re: How to install Java 8 on Raspbian?
Hi
I have just done a fresh install of the latest version of Raspian Stretch and Java wasn't installed.
I had to install it manually.
I have just done a fresh install of the latest version of Raspian Stretch and Java wasn't installed.
I had to install it manually.
- HawaiianPi
- Posts: 7599
- Joined: Mon Apr 08, 2013 4:53 am
- Location: Aloha, Oregon USA
Re: How to install Java 8 on Raspbian?
Only the Desktop version has it pre-installed. The Lite version would need you to install it. And the version in the repos is still super old.
Code: Select all
~ $ java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode)
Code: Select all
~ $ java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) Client VM (build 25.161-b12, mixed mode)
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups, and where is that annoying music coming from?
lots of pop-ups, and where is that annoying music coming from?
Re: How to install Java 8 on Raspbian?
You can also give a try to OpenJDK 10 or 9.
E.g. certified Liberica one https://bell-sw.com/pages/liberica-rele ... -Embedded/
There are .tar.gz and .deb download options.
E.g. certified Liberica one https://bell-sw.com/pages/liberica-rele ... -Embedded/
There are .tar.gz and .deb download options.
Last edited by Teapot on Sat Mar 20, 2021 1:15 am, edited 1 time in total.
-
- Posts: 1
- Joined: Fri May 04, 2018 10:35 am
Re: How to install Java 8 on Raspbian?
Hi,
Installation
First install dirmngr:
sudo apt-get install dirmngr
Second add deb repositories and key:
Warning! If you add xentail repositories (as many RPi forums and other pages state) you’ll end up with old 1.8.0_65 version, you must be using trusty repositories in order to install latest Java version.
Update repositories:
sudo apt-get update
Install Java installer:
1
Verify Java version
To be 100% sure I have proper version of Java I use basic command:
java -version
Remove old Java
In case you have old Java 8 JDK
Hope that Helps!
Regards,
Techtiq Solutions,
Installation
First install dirmngr:
Code: Select all
Second add deb repositories and key:
Code: Select all
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
Update repositories:
sudo apt-get update
Install Java installer:
1
Code: Select all
sudo apt-get install oracle-java8-jdk
To be 100% sure I have proper version of Java I use basic command:
java -version
Remove old Java
In case you have old Java 8 JDK
Code: Select all
sudo apt-get remove --purge oracle-java8-jdk
Hope that Helps!

Regards,
Techtiq Solutions,
- HawaiianPi
- Posts: 7599
- Joined: Mon Apr 08, 2013 4:53 am
- Location: Aloha, Oregon USA
Re: How to install Java 8 on Raspbian?
You just posted what I posted last year, only with incorrect information.
Nope, that is completely false. 8u65 is what's in the Raspbian repositories. Installed the way I outlined above you get the latest version.danieldixon wrote: ↑Fri May 04, 2018 10:46 amWarning! If you add xentail repositories (as many RPi forums and other pages state) you’ll end up with old 1.8.0_65 version, you must be using trusty repositories in order to install latest Java version.
Code: Select all
~ $ java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) Client VM (build 25.171-b11, mixed mode)
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups, and where is that annoying music coming from?
lots of pop-ups, and where is that annoying music coming from?
-
- Posts: 1
- Joined: Tue Jul 03, 2018 12:40 pm
Re: How to install Java 8 on Raspbian?
@HawaiianPi, Thank you! Worked wonderfully first time!
I read many pages and was never satisfied, until reading your post here.
Thanks again.
I read many pages and was never satisfied, until reading your post here.
Thanks again.
Re: How to install Java 8 on Raspbian?
I found myself without java on a pi and most of the howto's and help posts were outdated. Here's what worked for me.
sudo apt-get install java-runtime
Which produced the following error msg
"java-runtime is a virtual package provided by..."
and a list of available packages! So I chose a package to install.
sudo apt-get install package_name_here
Hope this helps somebody
sudo apt-get install java-runtime
Which produced the following error msg
"java-runtime is a virtual package provided by..."
and a list of available packages! So I chose a package to install.
sudo apt-get install package_name_here
Hope this helps somebody

- HawaiianPi
- Posts: 7599
- Joined: Mon Apr 08, 2013 4:53 am
- Location: Aloha, Oregon USA
Re: How to install Java 8 on Raspbian?
Yes, this post is old and outdated, which is why it should not have been bumped.
Oracle Java is no longer included with Raspbian. You can install OpenJDK instead.
To see what versions of the runtime environment are available.
Code: Select all
apt policy openjdk-*-jre
To see what versions of the development kit are available.
Code: Select all
apt policy openjdk-*-jdk
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups, and where is that annoying music coming from?
lots of pop-ups, and where is that annoying music coming from?
Re: How to install Java 8 on Raspbian?
Old or not this thread is at the top of google results, good thing it's got useful info now 
