Failed to start Jenkins after updating java

We encountered this issue after updating java on our build server. In our case we updated from Java 7 Update 80 to Java 8 update 111 ( a major version change) which you can guess changed the directories. Since the installer asked to remove older version of java, we did it. As you can guess, this left dependent applications unable to start as they were not able to find java files in the requisite folder anymore. Now while trying to run jenkins, we were getting below 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.WrapperService.StartProcess(Process process, String arguments, String executable)
 at winsw.WrapperService.OnStart(String[] _)
 at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)

If you have been following jenkins.exe earlier, you may have noted that it starts with below parameters:

Starting C:\Program Files\Java\jre7\bin\java -Xrs -Xms1024m -Xmx4096m 
-Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle 
-jar "C:\InstalledApps\Jenkins\jenkins.war" --httpPort=80 
--webroot="C:\InstalledApps\Jenkins\war"

Naturally, the hudson is unable to find the underlying java file. However, if we ran java -fullversion on a command prompt, it returned fine. So it seemed that it was using hard coded path for java. To remedy issue with jenkins service, go to directory where jenkins is installed, and open jenkins.xml. Change the path inside tag to correct java.exe path for java runtime environment which should be something like C:\Program Files\Java\jre1.8.0_111\bin\java. After this, start jenkins service and it will start fine.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s