Over a million developers have joined DZone.
Silver Partner

Make Jenkins Windows Service use your Preferred JRE

· Java Zone

The Java Zone is brought to you by Stormpath—offering a pre-built identity API for developers. Easily build powerful user management, authentication, and authorization into your web and mobile applications. Check out this tutorial to build a simple web app with Spring Boot and Spring Security in 15 minutes.

Recently I was working on installing and configuring a new instance of Jenkins. For some reason, which is out of this post’s context, I wanted to make Jenkins run with a specific version of the Java environment. Fortunately it was something really easy. This post is mainly a reminder to me, next time I’d like to do the same :)

Jenkins by default uses the jre which located under the jre sub-directory of your jenkins installation home ( %JENKINS_HOME ).

To change this find the file named jenkins.xml in which is located in your %JENKINS_HOME directory. 

Edit it and look for the following section

 <executable>%BASE%\jre\bin\java</executable>

Now change the content of the executable property to point to your favorite JRE. You can describe it as an absolute or relative path or you can even use, environment variables.

Save the file and restart Jenkins.

That’s it!

Enjoy!

The Java Zone is brought to you by Stormpath—offering a pre-built, streamlined user management API for building web and mobile applications. Learn how token authentication with JWTs (JSON Web Tokens) helps secure websites and avoids the pitfalls of using cookies and sessions.

Topics:

Published at DZone with permission of Patroklos Papapetrou , DZone MVB .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}