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: 28810
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: 28810
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: 1548
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: 1548
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

Return to “Java”

Who is online

Users browsing this forum: No registered users and 4 guests