Jenkins fails to start on Windows Server after Java Runtime update uninstalled older version of JRE
I have a Jenkins Server running on Windows Server 2012 and Java prompted me to update to a newer version (jre1.8.0_261 to jre1.8.0_271) and during that install it asked to uninstall older versions (for security reasons) which I allowed it to do. When I restarted Jenkins service it failed to restart. Error log indicates this Informational message:
Starting C:\Program Files\Java\jre1.8.0_261\\bin\java.exe -Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "C:\Program Files\Jenkins\jenkins.war" --httpPort=8080 --webroot="C:\Windows\system32\config\systemprofile\AppData\Local\Jenkins\war"
And this error:
Service cannot be started. System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at winsw.Util.ProcessHelper.StartProcessAndCallbackForExit(Process processToStart, String executable, String arguments, Dictionary2 envVars, String workingDirectory, Nullable1 priority, ProcessCompletionCallback callback, Boolean redirectStdin, LogHandler logHandler, Boolean hideWindow) at winsw.WrapperService.StartProcess(Process processToStart, String arguments, String executable, LogHandler logHandler, Boolean redirectStdin) at winsw.WrapperService.OnStart(String[] args) at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)
The informational message gave me a clue to the problem: Jenkins is pointing to the older version of Java location here: C:\Program Files\Java\jre1.8.0_261
However the folder is empty, most importantly there is no bin folder present (no doubt due to the aforementioned uninstall).
The newer version here has the full java binaries: C:\Program Files\Java\jre1.8.0_271
How do you get Jenkins to point to the new JRE?
Solution 1:
There is a pretty simple solution: locate the Jenkins.xml file (for me its located at C:\Program Files\Jenkins\jenkins.xml
) and edit it.
Locate the <executable>
element and correct it so that it points to the new JRE path, for example in my case I changed
this <executable>C:\Program Files\Java\jre1.8.0_261\bin\java.exe</executable>
to this <executable>C:\Program Files\Java\jre1.8.0_271\bin\java.exe</executable>
Save file and Jenkins starts up fine now.