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.
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.
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.
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.
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)
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.