Skip to main content

About a week ago I got contacted by Rosen Petrov on one of my previous blogposts: Installing SOLR 7.3.1 (on prem) with OpenJDK for Sitecore 9.1. He was working on changing his environments as well to make use of OpenJDK and ran into the same problem as I did.

He pointed me out to one of the scripts that Mark Cassidy released: Install-Solr.ps1, which I assumed would install java immediately as well. Due to the fact that I still had a c:\solr directory and a JAVA_HOME environment variable, the script failed. Cassidy actually mentioned to me that the script isn’t perfect but does its purpose.

OpenJDK implementations

Even though Cassidy’s script does its thing, in this short blog-post I still would like to show what we can use more than just the default OpenJDK implementation, since there are a lot. In this blog-post I’m going to use AdoptOpenJDK. AdoptOpenJDK provides prebuilt OpenJDK build binaries.

AdoptOpenJDK Install

So what I started with was to get AdoptOpenJDK installed, and then have that working with the recommend version for Sitecore 9.1 Update-1: SOLR 7.2.1.

So we first need to make sure that we have AdoptOpenJDK installed. As said in one of my previous blogpost, I’m using Chocolatey as my software automation tool.

Chocolatey is a package manager for Windows which allows you do quickly automate software installations. If you haven’t already installed it, make sure you install it here.

2 versions

Chocolatey however has 2 versions of the AdoptOpenJDK: AdoptOpenJDK and AdoptOpenJDK8 (the last one is the one we need for supporting SOLR 7.2.1)

Once installed make sure you open up a command prompt or Powershell prompt and run the following command:

  • choco install adoptopenjdk8

This will make sure that the latest version of the AdoptOpenJDK8 gets installed onto your local machine. The JAVA_HOME path variable gets added with a path of: C:\Program Files\AdoptOpenJDK\jdk8u212-b03

When we then check the Java version with the following command: java -version, we’ll get to see that Java has been setup correctly and that it’s using the OpenJDK:

PS C:\Windows\system32> java -version
openjdk version “1.8.0_212”
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_212-b03)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.212-b03, mixed mode)
PS C:\Windows\system32>

Execute SOLR Script

All you know need to to do is go to my Github page, download the Install-Solr-AdoptOpenJDK.ps1 script and execute it.

When the script finished SOLR 7.2.1 got installed as expected (see screenshot below)

You can download the final Install-Solr-AdoptOpenJDK.ps1 script here.

Thanks to Rosen Petrov for pointing me to AdoptOpenJDK…. If you’re curious about the many differences between the OpenJDK versions, make sure to read this Stackoverflow thread.

Happy Sitecore-ing…