User avatar
radu1337
Posts: 20
Joined: Tue Feb 18, 2014 2:03 pm

Updating Java on Raspbian from 1.7.0 to 1.8.0

Tue Feb 18, 2014 2:13 pm

Hello,

I just installed Raspbian which means it came pre-loaded with Java. I want to run a Minecraft server and all the tutorials online suggest running it with the following command:

Code: Select all

sudo /opt/jdk1.8.0/bin/java -Xms256M -Xmx496M -jar /home/pi/spigot.jar nogui
However it does not work. I checked java -version and I have 1.7.0_40, the only way I can run the server is like this:

Code: Select all

sudo java -Xms256M -Xmx496M -jar /home/pi/spigot.jar nogui
I'm thinking that version 1.8.0 might offer a better performance since I'm seeing that people create a new server in 200 seconds and start an existing one in 30, while it takes me 700 seconds to create a server and about 200 seconds to start an existing one.

So how do I update java to 1.8.0? Seams a simple question but I can't find anything on Google :)

I also reduced the memory shared to the GPU at 16MB and I'm wondering if pushing the CPU to 800mhz is dangerous without cooling, at 700mhz it goes up to 50 degrees Celsius when the minecraft server is running.
I once created an alias called "sudo".

User avatar
radu1337
Posts: 20
Joined: Tue Feb 18, 2014 2:03 pm

Re: Updating Java on Raspbian from 1.7.0 to 1.8.0

Tue Feb 18, 2014 4:22 pm

Ok, so I simply followed these instructions (making sure I use the latest download link, not the one in the examples). It works but typing: java -version still returns 1.7.0 (even though I followed the instructions correctly).

Startup is now 50 seconds. Still not 30 but much better.

I did not previously remove the java version that came with Raspbian. I'm not a linux expert but that should be ok, by default my system uses 1.7.0 and when minecraft is launched with this command it uses 1.8.0:

Code: Select all

sudo /opt/jdk1.8.0/bin/java -Xms256M -Xmx496M -jar /home/pi/spigot.jar nogui
Still. Am I right about this? Should I remove the older version of Java? Anyway of increasing performance?

:D
I once created an alias called "sudo".

Fidelius
Posts: 418
Joined: Wed Jan 01, 2014 8:40 pm

Re: Updating Java on Raspbian from 1.7.0 to 1.8.0

Tue Feb 18, 2014 4:27 pm

Java 8 is still in beta or release-candidate (RC) status, so not official yet, but beginning with mid of March it shall be going final.

I don't know how long it will take the Raspbian developers to include the new Java 8 into the Pi's apt-get packages then.
(The current Raspbian's Java 7 is version 1.7.0_40, when the one we can download from Oracle's Java site is 1.7.0_45 -- so not that bad, really, and I'm happy we have the fast Oracle Java in the apt-get packages at all.)


So far I didn't remove Raspbian's official Oracle Java 7 package, but just downloaded the tar.gz archive for Java 8 RC (b129 from February 2014) from here: https://jdk8.java.net/download.html
Then I unpacked it and (sudo) moved it to /opt/jdk1.8.0/

Since usually you have some .sh script to start your (bigger) Java applications anyway, I think this parallel "installation" or "untar-isation" of Java 8 to /opt works fine next to the apt-get's Java 7. You can happily use both JVMs in parallel, meaning the command "java" without path will take the Raspbian's standard Java 7, whilst "/opt/.../java" uses the new Java 8 beta then, as in your latest code quotation.
Is your Java 8 RC also b129? The Java 8 beta which the Elinux site mentioned seemed to be a year older.


Regarding speed improvements: Haven't done any number benchmarks yet. Usually new Java main versions bring speed improvements indeed. Would love to read about some. However JavaFX, which is new and built-in to Java 8, delivers hardware acclerated 2D and 3D to the masses without external native bindings, also on the Pi. You probably want to check it out for own projects.

User avatar
radu1337
Posts: 20
Joined: Tue Feb 18, 2014 2:03 pm

Re: Updating Java on Raspbian from 1.7.0 to 1.8.0

Tue Feb 18, 2014 5:47 pm

Thank you for your reply, it confirmed what I suspected :) I'll leave java 7 alone.

As to performance I can make some more tests with the minecraft server. Will post the results.
I once created an alias called "sudo".

User avatar
radu1337
Posts: 20
Joined: Tue Feb 18, 2014 2:03 pm

Re: Updating Java on Raspbian from 1.7.0 to 1.8.0

Tue Feb 18, 2014 7:53 pm

So I started and stopped the Minecraft server with both versions of java:

1.7.0_40-b43 => 73 seconds
1.8.0-b129 => 51 seconds

The 1.8.0 version sometimes even starts under 50 seconds.
I once created an alias called "sudo".

Fidelius
Posts: 418
Joined: Wed Jan 01, 2014 8:40 pm

Re: Updating Java on Raspbian from 1.7.0 to 1.8.0

Mon Feb 24, 2014 8:47 am

That's really great to see; what a fine speed-up. Thanks for the info.

Thus I decided to remove (Oracle) Java 7 and use (Oracle) Java 8 Release-Candidate instead. :-)
So I did an "apt-get remove oracle-java*" which worked, but somehow apt-get insisted on installing instead some "gjc" or how it's called, which is some kind of old and slow and partly-only GNU Java. Don't know how to get rid of it in Raspbian/Debian Linux. Anybody? (On a Xubuntu installation it worked, i.e. an "apt-get remove openjdk*" removed any Java entirely.)

Anyway, in the /etc/profile file I added the following line at the end :
PATH=/opt/jdk1.8.0/bin:"$PATH"

And now Java 8 is being used system-wide on the nice Pi. :-)


P.S. To set the /opt/ part at the start of the PATH is only necessary because I couldn't get rid of the "gjc" or how it is called in the system, which otherwise runs when you issue a "java ..." command. With the Xubuntu installation where any Java was removed successfully, the PATH /etc/profile is as expected:
PATH="$PATH":/opt/jdk1.8.0/bin

User avatar
radu1337
Posts: 20
Joined: Tue Feb 18, 2014 2:03 pm

Re: Updating Java on Raspbian from 1.7.0 to 1.8.0

Mon Feb 24, 2014 10:48 am

Cool :)
I once created an alias called "sudo".

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Updating Java on Raspbian from 1.7.0 to 1.8.0

Wed Mar 26, 2014 2:31 pm

In the oracle page linked they use jdk 1.8.0.
The last downloadable from oracle site is 1.8.0_20.
There is a way to handle Oracle JDK update automatically?

Fidelius
Posts: 418
Joined: Wed Jan 01, 2014 8:40 pm

Re: Updating Java on Raspbian from 1.7.0 to 1.8.0

Thu Mar 27, 2014 9:33 am

Well, once Java 8 is in Raspbian's repository, I suppose it would be updated automatically from time to time. Please see some of Henrik's recent posts concerning Java 8 and Raspbian :

Java 8 launch news
henrik wrote:We [Oracle team] are working with the foundation to make sure that the RPi repository is updated to add Oracle JDK 8. Oracle JDK 7 will continue to be available.
ANNOUNCE: Java 8 released
henrik wrote:I expect to see the Raspberry Pi Linux repository and Raspbian etc images to be updated with Oracle JDK 8 sometime soon.

Henrik - Oracle Java team

C-Fu
Posts: 88
Joined: Mon Nov 26, 2012 10:07 am
Location: Malaysia

Re: Updating Java on Raspbian from 1.7.0 to 1.8.0

Wed Feb 18, 2015 3:53 am

Fidelius wrote:That's really great to see; what a fine speed-up. Thanks for the info.

Thus I decided to remove (Oracle) Java 7 and use (Oracle) Java 8 Release-Candidate instead. :-)
So I did an "apt-get remove oracle-java*" which worked, but somehow apt-get insisted on installing instead some "gjc" or how it's called, which is some kind of old and slow and partly-only GNU Java. Don't know how to get rid of it in Raspbian/Debian Linux. Anybody? (On a Xubuntu installation it worked, i.e. an "apt-get remove openjdk*" removed any Java entirely.)

Anyway, in the /etc/profile file I added the following line at the end :
PATH=/opt/jdk1.8.0/bin:"$PATH"

And now Java 8 is being used system-wide on the nice Pi. :-)


P.S. To set the /opt/ part at the start of the PATH is only necessary because I couldn't get rid of the "gjc" or how it is called in the system, which otherwise runs when you issue a "java ..." command. With the Xubuntu installation where any Java was removed successfully, the PATH /etc/profile is as expected:
PATH="$PATH":/opt/jdk1.8.0/bin
I tried and it too installed gjc or something for some reason. but I have a weird problem. I can't find the folder /opt/jdk1.8.0 after I sudo apt-get install oracle-java8-jdk on RPi 2

Fidelius
Posts: 418
Joined: Wed Jan 01, 2014 8:40 pm

Re: Updating Java on Raspbian from 1.7.0 to 1.8.0

Wed Feb 18, 2015 5:09 am

C-Fu wrote:I tried and it too installed gjc or something for some reason. but I have a weird problem. I can't find the folder /opt/jdk1.8.0 after I sudo apt-get install oracle-java8-jdk on RPi 2
If I remember correctly, what I wrote last year about the /opt/jdk1.8.0/ path, does only apply if you manually untar-ed Oracle's Java8 tar-ball and moved it to there.

Since some time Oracle's Java8 is in the Raspbian repository, so you can do your mentioned apt-get install and then after the install the Java8 path should either be already in your path, or you can still add it manually like I mentioned, but then let it point to the standard Raspbian JVM path which is:
/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/

(I'm sure there's some Raspbian-official file-link to this /usr/lib/jvm/jdk-8-... , but I wouldn't know where, since I always use the tar-ball-ed JVM.)

Return to “Raspbian”