1

The script from Jeremy Davis Downloads, installs, adds SSL and sets up Solr as windows service. However, JRE is required for Solr and JRE needs to be installed manually. Is there anyway to download and install JRE with PowerShell?

  • I'm new to StackExchange, is there a reason why I can't edit my own question. The title should be. "How to download and installl JRE with PowerShell for Sitecore Solr installation." – Ercan Polat Aug 4 at 0:55
1

Actually, I did find out a way to download and install JRE with PowerShell script.It is really use-full therefore I wanted to share it here in StackExchange. This script can be optimized but it does the job as it is.

Below is the entire script: https://github.com/erjan123/Sitecore/blob/master/Sitecore/PowershellScripts/Sitecore%20Solr/2.install-solr-7.5-and-JRE.ps1

I have also a tutorial that explains the script: https://www.youtube.com/watch?v=3-27syl8C98&t=10s

    $downloadInstallJRE = $true,
    $JREVersion64 = $true  

    if($downloadInstallJRE -eq $true)
{
    if($JREVersion64 -eq $true)
    {
        $URL=(Invoke-WebRequest -UseBasicParsing https://www.java.com/en/download/manual.jsp).Content |     ForEach-Object{[regex]::matches($_, '(?:<a title="Download Java software for Windows \(64-bit\)" href=")(.*)(?:">)').Groups[1].Value} 
    }
    else
    {       
        $URL=(Invoke-WebRequest -UseBasicParsing https://www.java.com/en/download/manual.jsp).Content | ForEach-Object{[regex]::matches($_, '(?:<a title="Download Java software for Windows Online" href=")(.*)(?:">)').Groups[1].Value}
    }
        Invoke-WebRequest -UseBasicParsing -OutFile jre8.exe $URL
        Start-Process .\jre8.exe '/s REBOOT=0 SPONSORS=0 AUTO_UPDATE=0' -wait

    if($JREVersion64 -eq $true)
    {
        $JREVersion = Get-ChildItem -Path "C:\Program Files\Java" -name | Where-Object { -not $_.PsIsContainer } | Sort-Object LastWriteTime -Descending | Select-Object -first 1 

        Write-Host "JREVersion: $JREVersion"
        $JREPath = "C:\Program Files\Java\$JREVersion"
        Write-Host  "JREPath" + $JREPath
        Write-Host "Downloading 64 bit of JRE"
    }   
    else{

        $JREVersion = Get-ChildItem -Path "C:\Program Files (x86)\Java" -name | Where-Object { -not $_.PsIsContainer } | Sort-Object LastWriteTime -Descending | Select-Object -first 1 

        Write-Host "JREVersion: $JREVersion"
        $JREPath = "C:\Program Files (x86)\Java\$JREVersion"
        Write-Host  "JREPath " + $JREPath
        Write-Host "Downloading 32 bit of JRE"
    }

        Write-Host "JRE package URL " $URL
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.