Skip to content

Install Java using Jenv

On both Linux and MacOS, follow the official jenv install procedure.

Then, download the required Java JDK and add them to jenv:

Linux

On linux, copy/paste the hole script bellow (and modify $JAVA_INSTALL_DIR if needed):

git clone https://github.com/jenv/jenv.git ~/.jenv
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(jenv init -)"' >> ~/.bashrc
source ~/.bashrc
export JAVA_INSTALL_DIR=~/opt/java
mkdir -p $JAVA_INSTALL_DIR

cd $JAVA_INSTALL_DIR
# Here replace with appropriate version for your platform (see https://adoptopenjdk.net/archive.html?variant=openjdk8&jvmVariant=hotspot)

# MINIMUM VERSION is 8u252

wget https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u252-b09/OpenJDK8U-jdk_x64_linux_hotspot_8u252b09.tar.gz
tar -zxvf OpenJDK8U-jdk_x64_linux_hotspot_8u252b09.tar.gz
rm OpenJDK8U-jdk_x64_linux_hotspot_8u252b09.tar.gz
jenv add jdk8u252-b09
source ~/.bashrc
jenv enable-plugin export
jenv global 1.8.0.252  # use jenv versions to see the choices

Troubleshooting

minimum openjdk

In some versions of openjdk (eg 8u222), incompatible SSL behaviour makes unit tests of bootstrap-lib fail:

[INFO] Punch Platform Core Library 6.1.0 ......... FAILURE [ 5.224 s] [ERROR] Failures: [ERROR] UtilSslTest.loadTrustStore:63 cert 1 not null ==> expected: not [INFO] [ERROR] Tests run: 68, Failures: 1, Errors: 0, Skipped: 0 [INFO] Running org.thales.punch.libraries.elasticsearch.utils.api.UtilSslTest 11:48:03 [ERROR] message="Unable to load keystore material. Password may be wrong or key is corrupted" 11:48:03 [ERROR] message="Unsupported keystore type" type=txt path=/tmp/no_keystore.txt [ERROR] Tests run: 5, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.047 s <<< FAILURE! - in org.thales.punch.libraries.elasticsearch.utils.api.UtilSslTest [ERROR] loadTrustStore Time elapsed: 0.019 s <<< FAILURE! org.opentest4j.AssertionFailedError: cert 1 not null ==> expected: not > at org.thales.punch.libraries.elasticsearch.utils.api.UtilSslTest.loadTrustStore(UtilSslTest.java:63)

The solution is to replace (using apt update, or jenv) your old openjdk with a newer one...