Skip to content

Instantly share code, notes, and snippets.

@jeremywall
Last active August 9, 2023 08:09
Show Gist options
  • Save jeremywall/bc585f92838e78cc3f9916522de6cd00 to your computer and use it in GitHub Desktop.
Save jeremywall/bc585f92838e78cc3f9916522de6cd00 to your computer and use it in GitHub Desktop.
Compile and install new TZDB for Java
# I recently had to try to update the TZDB of a JDK installation where I could not install lzip
# from any registered package repository and trying to compile lzip from source was failing.
# I discovered that as an alternative to using the tzdb-latest.tar.lz file I could just use both
# the tzcode-latest.tar.gz and the tzdata-latest.tar.gz to generate the needed rearguard tarballs.
# These instructions have been updated to no longer rely on lzip since it's not available out of
# the box in many environments.
# SHORTCUT ALERT: If you don't want to go through the whole process to build the rearguard tarball
# or use the ziupdater tool to generate and install a tzdb.dat file you can always just download
# the latest tar.gz and tzdb.dat files from a repo I created that automatically builds new TZDB
# releases as they come out. This repo is at https://github.com/jeremywall/tzdb-builder/releases
# make a new working directory first
mkdir tzdb
cd tzdb
# download the latest tzcode and tzdata archives
wget https://data.iana.org/time-zones/tzcode-latest.tar.gz
wget https://data.iana.org/time-zones/tzdata-latest.tar.gz
# decompress the archives into the current directory
tar xzfv tzcode-latest.tar.gz
tar xzfv tzdata-latest.tar.gz
# make the rearguard version, the result output file will be tzdataVERSION-rearguard.tar.gz where VERSION is the version number
make rearguard_tarballs
# get the ziupdater tool from https://www.azul.com/products/open-source-tools/ziupdater-time-zone-tool/
# place the ziupdater-x.y.z.jar and the tzdataVERSION-rearguard.tar.gz on the machine you want to update
# stop Java processes
# run the ziupdater
sudo java -jar ziupdater-x.y.z.jar -l file:///home/username/path/to/tzdataVERSION-rearguard.tar.gz
# correct the permission of the tzdb file that was installed
# for oracle java 8 it's at /usr/lib/jvm/java-8-oracle/jre/lib/tzdb.dat
# for corretto java 8 it's at /usr/lib/jvm/java-1.8.0-amazon-corretto/jre/lib/tzdb.dat
# for corretto java 11 it's at /usr/lib/jvm/java-11-amazon-corretto/lib/tzdb.dat
sudo chmod 644 /usr/lib/jvm/java-1.8.0-amazon-corretto/jre/lib/tzdb.dat
# start java processes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment