HowTo: Install Zulu Embedded Java on Raspberry Pi 3

try:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xB1998361219BD9C9

and then apt-get update

http://docs.azul.com/zulu/zuludocs/#ZuluUserGuide/PrepareZuluPlatform/AttachAPTRepositoryUbuntuOrDebianSys.htm

I wouldn’t recommend the use of the Zulu repo for installations of Zulu Embedded. It appears to be out of date and the latest version available is below the one recommended by openHAB.

I haven’t used Zulu for a while…

is there another source (repo) available for zulu-embedded-8 packages?

I don’t believe so, instead one would have to download the <zulu_package>.tar.gz file from the website:

sudo mkdir /opt/jdk/
cd /opt/jdk
sudo wget <.tar.gz_download_link>
sudo tar -xzvf <zulu_package>.tar.gz
sudo update-alternatives --install /usr/bin/java java /opt/jdk/<zulu_package>/bin/java <priority>
sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/<zulu_package>/bin/javac <priority>
sudo rm <zulu_package>.tar.gz
sudo apt purge zulu-embedded-8

Where <priority> is any integer number usually representing the version you’re downloading.

If there are multiple versions installed. You can select between them with:

sudo update-alternatives --config java
sudo update-alternatives --config javac

@mstormi has created a PR so that this can be done in openHABian.

2 Likes

I think that they have a different versioning method… their zulu-embedded-8 packages (available on their repo) seem to be:

zulu-embedded-8 |  8.25.0.76 = OpenJDK 1.8 Build 152
zulu-embedded-8 |  8.20.0.42 = OpenJDK 1.8 Build 121
zulu-embedded-8 |  8.19.0.31 = OpenJDK 1.8 Build ???

so in theory, we are ok with regards to the min requirements (1.8 Build 101?). What do you think @Benjy ?

Anyway… the PR is in the right direction since Azul does not update it’s repos anymore (I just saw it)

Not anymore :wink:

1 Like

Strange… although it was merged 5 days ago, I still see 101:

on https://www.openhab.org/docs/installation/#prerequisites

btw, I opened up a small issue also: [#809]
I will make the PR now also (when I edit the openhab-docs/installation/index.md I see 161)
PR done: [#810]

1 Like

Never heard of Zulu; sorry, but their download site is a shocker, as it does not tel which of all these versions I need to install.
I adopted apt-get packages, as these are straightforward to install.
Since I only understood half of what you guys were saying (since my post); can someone please indicate what I should do; either install java, wait for Zulu to be sorted, or else?
Thanks.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0x219BD9C9
Segmentation fault
Executing: /tmp/apt-key-gpghome.79ETrTYrty/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0x219BD9C9
gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory
gpg: connecting dirmngr at '/tmp/apt-key-gpghome.79ETrTYrty/S.dirmngr' failed: No such file or directory
gpg: keyserver receive failed: No dirmngr

or

sudo apt-get update
Hit:1 http://archive.raspberrypi.org/debian stretch InRelease
Ign:2 http://repos.azulsystems.com/debian stable InRelease
Hit:3 http://repos.azulsystems.com/debian stable Release
Get:4 http://repos.azulsystems.com/debian stable Release.gpg [819 B]
Hit:5 http://raspbian.raspberrypi.org/raspbian stretch InRelease
Ign:4 http://repos.azulsystems.com/debian stable Release.gpg
Fetched 819 B in 2s (342 B/s)
Reading package lists... Done
W: GPG error: http://repos.azulsystems.com/debian stable Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B1998361219BD9C9
W: The repository 'http://repos.azulsystems.com/debian stable Release' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.

I thought bugger it; imaged with Stretch Lite (2018-10-09-raspbian-stretch-lite) and went straight into the Java8 install… which failed, based on https://gist.github.com/ribasco/fff7d30b31807eb02b32bcf35164f11f … adding key and repo worked, but trying to install java failed:

sudo apt-get install oracle-java8-installer
# asks for two confirmations to accept license terms

maxg@rpi3ohv2:~ $ sudo apt-get install oracle-java8-installer
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  gsfonts gsfonts-x11 java-common libfontenc1 libxfont1 oracle-java8-set-default x11-common xfonts-encodings xfonts-utils
Suggested packages:
  binfmt-support visualvm ttf-baekmuk | ttf-unfonts | ttf-unfonts-core ttf-kochi-gothic | ttf-sazanami-gothic ttf-kochi-mincho
  | ttf-sazanami-mincho ttf-arphic-uming firefox | firefox-2 | iceweasel | mozilla-firefox | iceape-browser | mozilla-browser
  | epiphany-gecko | epiphany-webkit | epiphany-browser | galeon | midbrowser | moblin-web-browser | xulrunner | xulrunner-1.9 | konqueror
  | chromium-browser | midori | google-chrome
The following NEW packages will be installed:
  gsfonts gsfonts-x11 java-common libfontenc1 libxfont1 oracle-java8-installer oracle-java8-set-default x11-common xfonts-encodings
  xfonts-utils
0 upgraded, 10 newly installed, 0 to remove and 4 not upgraded.
Need to get 4,226 kB of archives.
After this operation, 6,465 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial/main armhf oracle-java8-installer all 8u191-1~webupd8~1 [33.1 kB]
Get:4 http://ppa.launchpad.net/webupd8team/java/ubuntu xenial/main armhf oracle-java8-set-default all 8u191-1~webupd8~1 [6,968 B]
Get:2 http://mirror.reap.net.nz/raspbian/raspbian stretch/main armhf java-common all 0.58 [13.5 kB]
Get:3 http://mirror.reap.net.nz/raspbian/raspbian stretch/main armhf gsfonts all 1:8.11+urwcyr1.0.7~pre44-4.3 [3,126 kB]
Get:5 http://mirror.reap.net.nz/raspbian/raspbian stretch/main armhf libfontenc1 armhf 1:1.1.3-1 [22.2 kB]
Get:6 http://mirror.reap.net.nz/raspbian/raspbian stretch/main armhf libxfont1 armhf 1:1.5.2-4 [120 kB]
Get:7 http://mirror.reap.net.nz/raspbian/raspbian stretch/main armhf x11-common all 1:7.7+19 [251 kB]
Get:8 http://mirror.reap.net.nz/raspbian/raspbian stretch/main armhf xfonts-encodings all 1:1.0.4-2 [574 kB]
Get:9 http://mirror.reap.net.nz/raspbian/raspbian stretch/main armhf xfonts-utils armhf 1:7.7+4 [70.4 kB]
Get:10 http://mirror.reap.net.nz/raspbian/raspbian stretch/main armhf gsfonts-x11 all 0.24 [8,922 B]
Fetched 4,226 kB in 7s (551 kB/s)
Preconfiguring packages ...
Selecting previously unselected package java-common.
(Reading database ... 34599 files and directories currently installed.)
Preparing to unpack .../java-common_0.58_all.deb ...
Unpacking java-common (0.58) ...
Selecting previously unselected package oracle-java8-installer.
Preparing to unpack .../oracle-java8-installer_8u191-1~webupd8~1_all.deb ...
Unpacking oracle-java8-installer (8u191-1~webupd8~1) ...
Setting up java-common (0.58) ...
Setting up oracle-java8-installer (8u191-1~webupd8~1) ...
No /var/cache/oracle-jdk8-installer/wgetrc file found.
Creating /var/cache/oracle-jdk8-installer/wgetrc and
using default oracle-java8-installer wgetrc settings for it.
Downloading Oracle Java 8...
--2018-11-11 10:05:59--  http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-arm32-vfp-hflt.tar.gz
Resolving download.oracle.com (download.oracle.com)... 23.12.50.210
Connecting to download.oracle.com (download.oracle.com)|23.12.50.210|:80... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://edelivery.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-arm32-vfp-hflt.tar.gz [following]
--2018-11-11 10:05:59--  https://edelivery.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-arm32-vfp-hflt.tar.gz
Resolving edelivery.oracle.com (edelivery.oracle.com)... 23.12.54.107, 2600:1415:8:192::2d3e, 2600:1415:8:183::2d3e
Connecting to edelivery.oracle.com (edelivery.oracle.com)|23.12.54.107|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-arm32-vfp-hflt.tar.gz?AuthParam=1541894880_ac6946b39ed8b78903530ab9e01b6536 [following]
--2018-11-11 10:06:01--  http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-arm32-vfp-hflt.tar.gz?AuthParam=1541894880_ac6946b39ed8b78903530ab9e01b6536
Connecting to download.oracle.com (download.oracle.com)|23.12.50.210|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-arm32-vfp-hflt.tar.gz?AuthParam=1541894880_ac6946b39ed8b78903530ab9e01b6536 [following]
--2018-11-11 10:06:01--  https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-arm32-vfp-hflt.tar.gz?AuthParam=1541894880_ac6946b39ed8b78903530ab9e01b6536
Connecting to download.oracle.com (download.oracle.com)|23.12.50.210|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 76516807 (73M) [application/x-gzip]
Saving to: ‘jdk-8u191-linux-arm32-vfp-hflt.tar.gz’

     0K ........ ........ ........ ........ ........ ........  4% 1.54M 45s
  3072K ........ ........ ........ ........ ........ ........  8% 2.16M 37s
  6144K ........ ........ ........ ........ ........ ........ 12% 1.64M 37s
  9216K ........ ........ ........ ........ ........ ........ 16% 1.36M 37s
 12288K ........ ........ ........ ........ ........ ........ 20% 1.23M 38s
 15360K ........ ........ ........ ........ ........ ........ 24%  493K 49s
 18432K ........ ........ ........ ........ ........ ........ 28% 1.71M 44s
 21504K ........ ........ ........ ........ ........ ........ 32% 1.77M 40s
 24576K ........ ........ ........ ........ ........ ........ 37% 1.29M 37s
 27648K ........ ........ ........ ........ ........ ........ 41% 1.32M 34s
 30720K ........ ........ ........ ........ ........ ........ 45% 1.32M 32s
 33792K ........ ........ ........ ........ ........ ........ 49%  599K 32s
 36864K ........ ........ ........ ........ ........ ........ 53% 1.07M 30s
 39936K ........ ........ ........ ........ ........ ........ 57% 1.13M 27s
 43008K ........ ........ ........ ........ ........ ........ 61% 1.08M 25s
 46080K ........ ........ ........ ........ ........ ........ 65% 1.12M 22s
 49152K ........ ........ ........ ........ ........ ........ 69% 1.22M 19s
 52224K ........ ........ ........ ........ ........ ........ 74% 1.01M 17s
 55296K ........ ........ ........ ........ ........ ........ 78%  898K 14s
 58368K ........ ........ ........ ........ ........ ........ 82% 1.03M 12s
 61440K ........ ........ ........ ........ ........ ........ 86%  998K 9s
 64512K ........ ........ ........ ........ ........ ........ 90%  895K 6s
 67584K ........ ........ ........ ........ ........ ........ 94% 1.15M 4s
 70656K ........ ........ ........ ........ ........ ........ 98%  985K 1s
 73728K ........ .......                                     100% 1.01M=67s

2018-11-11 10:07:09 (1.08 MB/s) - ‘jdk-8u191-linux-arm32-vfp-hflt.tar.gz’ saved [76516807/76516807]

Download done.
Removing outdated cached downloads...
Segmentation fault
Segmentation fault
dpkg: error processing package oracle-java8-installer (--configure):
 subprocess installed post-installation script returned error exit status 139
Errors were encountered while processing:
 oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)

# Verify that we have successfully installed java
java -version
-> -bash: java: command not found

On that note, and that Zulu is the preferred OHv2 set-up, is there somebody who has successfully installed Zulu on a new Stretch Lite on a rPi3 and can list the steps taken to get there.

I get the principle of it; e.g. if there is no apt-get install, a key needs to be added, then a repo added, then apt-get update to download the files; then install the package with apt-get install. However non of the docu I have tried gets me there: neither java nor zulu.
Any help appreciated.

If you go the Zulu way, you can follow Ben’s instructions here: HowTo: Install Zulu Embedded Java on Raspberry Pi 3

This is the manual (not apt) based method to install since Zulu packages are not up to date.

If you go the Oracle way using apt, try:

sudo su
rm /etc/apt/sources.list.d/zulu.list /etc/apt/sources.list.d/webupd8team-java.list
rm -rf /var/cache/oracle-jdk8-installer/
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
apt-get autoclean
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C2518248EEA14886
apt-get update
apt-get install oracle-java8-installer oracle-java8-set-default
apt-get purge zulu-embedded-8

both ways are fine for OH2

Thanks for hanging in there!

Started again, and instead of doing my basic (standard) config, I went straight to the Java install.
After neither one completed, and showed segmentation errors, I got suspicious about the 16GB SanDisk SD card; am currently testing it, and it has thrown umpteen sector errors. This is good enough to get some new cards in the local shop and start over.
Interestingly enough this 16GB card has been running for 420 days, before I used it yesterday to build a OHv2 rPi3.

Is it safe to say that Zulu is where OH is going?
The tar ball I downloaded had eval in its name; and I see pricing information for their product on their site. Can we be sure this package remains ‘free’ to use? If I understand this JAva business somewhat, it seems Oracle wants some money if used in production, and whoever can afford it will leave this brand behind, why it is no longer included in distros?!
If all this has some merit, and Zulu is the next best thing, then this is the way forward, and the way that should be promoted.
Will update in the coming days how the new card went.

1 Like

I think so. It is (currently) the recommended Java framework to run OH2 on top.

From what I understand, Zulu (standard & embedded) will remain open & free (of charge) since it is based on OpenJDK.
The pricing on their site with regards to Zulu embedded seems to be related to (optional) support plans targeting custom developments? (not sure)
Of course… you can never tell with these companies… they may change their commercial policy over night :slight_smile:

Ps: I use the devil (Oracle) and I don’t really care about their licensing since I don’t use it in a commercial/production environment :stuck_out_tongue:

After getting a new brand SD card… another stab at this…

I have used your instructions as follows:

sudo mkdir /opt/jdk/
cd /opt/jdk
sudo wget http://cdn.azul.com/zulu-embedded/bin/zulu8.31.1.122-jdk1.8.0_181-linux_aarch64.tar.gz
sudo tar -xzvf zulu8.31.1.122-jdk1.8.0_181-linux_aarch64.tar.gz
sudo update-alternatives --install /usr/bin/java java /opt/jdk/zulu8.31.1.122-jdk1.8.0_181-linux_aarch64/bin/java 181
sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/zulu8.31.1.122-jdk1.8.0_181-linux_aarch64/bin/javac 181
sudo rm zulu8.31.1.122-jdk1.8.0_181-linux_aarch64.tar.gz

The commands above went well; however, these:

maxg@rpi3ohv2:/opt/jdk $ sudo apt purge zulu-embedded-8
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package zulu-embedded-8
maxg@rpi3ohv2:/opt/jdk $ java -version
-bash: /usr/bin/java: cannot execute binary file: Exec format error

ended in errors.

Unfortunately I have no clue on how to solve this.
Found your other post:


… which is essentially what you posted here.
Any hints appreciated.

Just noticed the owner of the directory:

drwxr-xr-x 3 root root 4096 Nov 12 20:51 .
drwxr-xr-x 4 root root 4096 Nov 12 20:43 ..
drwxrwxr-x 9  111  122 4096 Aug  1 05:14 zulu8.31.1.122-jdk1.8.0_181-linux_aarch64

111 and 112 – never seen this, should I change this to root?!

1 Like

Sorry, should have mentioned that there’s a different version for each “architecture”, since you’re using a PI3 with a 32bit OS (the recommended) you’ll be wanting:

http://cdn.azul.com/zulu-embedded/bin/zulu8.31.1.122-jdk1.8.0_181-linux_aarch32hf.tar.gz

Despite the similarity in name, post and subject area, that’s not me. :wink:

2 Likes

Again, thank you for helping me out!

We have a winner.

java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (Zulu 8.31.1.122-linux_aarch32hf) (build 1.8.0_181-b122)
OpenJDK Client VM (Zulu 8.31.1.122-linux_aarch32hf) (build 25.181-b122, mixed mode, Evaluation)

I actually noticed that the 64-bit was wrong; removed it, including the links, and installed the 32-bit soft float package, which didn’t work either; but this one ‘hard float’ does.

To summarise the steps, which worked for me based on your post:

sudo mkdir /opt/jdk/
cd /opt/jdk
sudo wget http://cdn.azul.com/zulu-embedded/bin/zulu8.31.1.122-jdk1.8.0_181-linux_aarch32hf.tar.gz
sudo tar -xzvf zulu8.31.1.122-jdk1.8.0_181-linux_aarch32hf.tar.gz

sudo update-alternatives --install /usr/bin/java java /opt/jdk/zulu8.31.1.122-jdk1.8.0_181-linux_aarch32hf/bin/java 181
sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/zulu8.31.1.122-jdk1.8.0_181-linux_aarch32hf/bin/javac 181

sudo rm zulu8.31.1.122-jdk1.8.0_181-linux_aarch32hf.tar.gz
sudo apt purge zulu-embedded-8
java -version
9 Likes

Looks like you downloaded a tar.gz file that is not matching with your current architecture.

For instance, on a rpi, you will need to download ARM 64-bit tar gz file, not the regular x86 64-bit one.

No, for most Raspbian installs you need the 32-bit ARM file. Here is the link openHABian uses.

https://cdn.azul.com/zulu-embedded/bin/zulu8.40.0.178-ca-jdk1.8.0_222-linux_aarch32hf.tar.gz

True, figured it out once I tried with the arm64 archive :slight_smile:

(btw, I wondered which 32b version to get, between hard floating point and soft floating point version … looks like getting the hf version was the recommended one since it’s the one matching your suggestion :-))

I copied the link from the OpenHABian repo. If that did not work we would know.

Thank you! with this guide I could install JAVA and openhab2 on my Raspberry Pi Zero W V1 :slight_smile: