How to install Java 8?

the recommended zulu repositories are not available.
I downloaded Oracle JDK1.8.0_231 on to my machine, unpacked it, but can’t figure out how to install it.

How do I get my machine to run it?


I ran into the zulu repository thing earlier today too. Not sure what is going on, it was working earlier in the week. Here are the steps that I followed, and I was able to get it running. This was on a fresh openhabian install on a Raspberry Pi, so the URL is for the ARM version:

  1. Download a good copy of zulu java. This thread from a few days ago recommends 1.8.0_222, but it wouldn’t actually run for me so I used

  2. Extract the archive into /opt/jdk: sudo tar -xzf zulu8.31.1.122-jdk1.8.0_181-linux_aarch32hf.tar.gz -C /opt/jdk

  3. Confirm that it works. This is where 222 failed for me. /opt/jdk/zulu8.31.1.122-jdk1.8.0_181-linux_aarch32hf/bin/java --version should output a version number, not an error.

  4. Set your newly-unpacked java as the default system java. Benjy kindly posed the instructions: sudo update-alternatives --install /usr/bin/java java /opt/jdk/zulu8.31.1.122-jdk1.8.0_181-linux_aarch32hf/bin/java 1 and sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/zulu8.31.1.122-jdk1.8.0_181-linux_aarch32hf/bin/javac 1

  5. At this point you should have working Java. For me I had a half-installed openhab and re-running /boot/first-boot.bash would still error out trying to install java. I edited out the line java_install_or_update "$java_arch" from /opt/openhabian/ (somewhat based on this thread) then ran that file (without running first-boot.bash, which seems to recreate sudo bash /opt/openhabian/ and had a fully-installed openhab.

  6. All that should be left are the last two steps contained in first-boot.bash: sudo rm -f /opt/openHABian-install-inprogress; sudo touch /opt/openHABian-install-successful

I’m hopeful that this was just someone at Azul pushing to prod on a Friday and not answering pages the whole weekend.

So, my java broke after a reboot. Looking at it now, I’m not sure how it worked before the reboot. There are 4 things that /opt/openhabian/functions/java-jre.bash does that I didn’t do:

  echo "$jdkLib"/"$jdkArch" > /etc/
  echo "$jdkLib"/"$jdkArch"/jli >> /etc/


the first three are pretty easy; $jdkLib is /opt/jdk/zulu8.31.1.122-jdk1.8.0_181-linux_aarch32hf/lib and $jdkArch is aarch32hf in this example.

The crypto extension I have no clue about.

For now I apt-get installed OpenJDK which seems to run fine. I than installed everything else through the openhabian-config manual install options just skipping the Java one. It’s been working through reboots and I haven’t noticed any performance issues compared to Zulu.

There are many sorts of machines. I don’t think it’s the same as my machine. :slight_smile: Which one do you have (OS, version etc.)?

Thanks to all who replied. I finally figured this out using your hints along with web searches.

I am doing a clean install of Openhab 2.5.0-snapshot on a new raspberry pi 4.

apparently I was unpacking java files correctly but I need to add the path to my Bash profile, so now Java -version reports a valid version.

Are you using a Debian variant (like Raspian or Openhabian)? If so, rather than set the path you’ll want to use update-alternatives, which is Debian’s method of managing multiple versions of an installed package. It basically chooses which one to symlink into /usr/bin based on version numbers with the possibility of a manual override.

Here’s what my desktop’s java configuration looks like right now:

ryan@apollo:~$ update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                         Priority   Status
  0            /usr/lib/jvm/java-13-openjdk-amd64/bin/java   1211      auto mode
* 1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      manual mode
  2            /usr/lib/jvm/java-13-openjdk-amd64/bin/java   1211      manual mode

Press <enter> to keep the current choice[*], or type selection number: 

I have java 11 and 13 installed, and I’ve manually selected java 11 because I was doing dev work on a Java 11 project, but I can always switch back to the latest if I want.

update-alternatives doesn’t seem to recognize Java

pi@OpenHAB2:~$ update-alternatives --config java
update-alternatives: error: no alternatives for java

my java is in /usr/java but maybe it should be somewhere else?

You have to tell it about your manually-installed version, that’s what step 4 was doing:

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

Your path to Java will be different, since you went with OpenJDK