rpi25
Posts: 23
Joined: Sat Feb 21, 2015 2:31 am

How to install Java 8 on Raspbian?

Tue Feb 24, 2015 5:31 am

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

User avatar
DougieLawson
Posts: 29765
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: How to install Java 8 on Raspbian?

Tue Feb 24, 2015 9:25 am

sudo apt-get install oracle-java8-jdk

Although on a stock Raspbian (or NOOBS) 2015-02-16 install it's already there.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

rpi25
Posts: 23
Joined: Sat Feb 21, 2015 2:31 am

Re: How to install Java 8 on Raspbian?

Tue Feb 24, 2015 8:12 pm

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

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.
Which is confusing, as the java 8 package you mention is clearly installed. Any idea what is wrong here?

User avatar
DougieLawson
Posts: 29765
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: How to install Java 8 on Raspbian?

Tue Feb 24, 2015 8:14 pm

Your code has thrown an exception. You'll need to read the source code to understand why it has done that.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

rpi25
Posts: 23
Joined: Sat Feb 21, 2015 2:31 am

Re: How to install Java 8 on Raspbian?

Tue Feb 24, 2015 9:25 pm

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

asandford
Posts: 1667
Joined: Mon Dec 31, 2012 12:54 pm
Location: Ealing

Re: How to install Java 8 on Raspbian?

Tue Feb 24, 2015 9:46 pm

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
A more 'portable' way is to set the JAVA_HOME env variable to point to the appropiate version for your project.

rpi25
Posts: 23
Joined: Sat Feb 21, 2015 2:31 am

Re: How to install Java 8 on Raspbian?

Tue Feb 24, 2015 11:05 pm

So in this instance, where would I find the home variable to redirect? Is that in the filebot.sh script, or elsewhere?

asandford
Posts: 1667
Joined: Mon Dec 31, 2012 12:54 pm
Location: Ealing

Re: How to install Java 8 on Raspbian?

Tue Feb 24, 2015 11:36 pm

rpi25 wrote:So in this instance, where would I find the home variable to redirect? Is that in the filebot.sh script, or elsewhere?
You can set it from the CLI: export JAVA_HOME=/path/to/java/version/you/want

simonx314
Posts: 4
Joined: Sun Mar 20, 2016 8:13 pm

Re: How to install Java 8 on Raspbian?

Sat Oct 22, 2016 7:26 pm

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
Thanks rpi25, running these two commands was what I needed to do to fix my javac java version mismatch.

henryburkhard
Posts: 2
Joined: Thu Aug 06, 2015 7:41 pm

Re: How to install Java 8 on Raspbian?

Thu Feb 16, 2017 1:12 am

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

User avatar
palswim
Posts: 15
Joined: Thu Jan 09, 2014 9:15 pm

Re: How to install Java 8 on Raspbian?

Tue Aug 22, 2017 2:52 pm

DougieLawson wrote:
Tue Feb 24, 2015 9:25 am
sudo apt-get install oracle-java8-jdk
My Raspbian repository does not appear to contain this package. Am I missing a source or did Raspbian remove this package from the repository?

DirkS
Posts: 7538
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: How to install Java 8 on Raspbian?

Tue Aug 22, 2017 4:18 pm

palswim wrote:
Tue Aug 22, 2017 2:52 pm
DougieLawson wrote:
Tue Feb 24, 2015 9:25 am
sudo apt-get install oracle-java8-jdk
My Raspbian repository does not appear to contain this package. Am I missing a source or did Raspbian remove this package from the repository?
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

User avatar
HawaiianPi
Posts: 1061
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: How to install Java 8 on Raspbian?

Mon Oct 09, 2017 3:29 pm

Yea, it's in the RPF Stretch repo as well.

HawaiianPi@CreeperPi:~ $ apt-cache policy oracle-java8-jdk
oracle-java8-jdk:
Note that it is quite an old version. The current version from Oracle is 8u144. If you want to update to the latest version you can install it manually, but an easier way is to use the webupd8team PPA, which will install and update Java like other packages. Also, if the above shows you have the old version installed, you'll want to remove it after we get you updated to the latest version (but don't try to remove it now).

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
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.

Code: Select all

apt-get update
apt-get install oracle-java8-installer
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.
My password is the last 8 digits of Pi.

Return to “Java”

Who is online

Users browsing this forum: No registered users and 3 guests