Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins, specifying JAVA_HOME

Tags:

I installed openjdk-6-jdk on my ubuntu box using apt-get.

In system info jenkins is telling me Java.Home is /usr/lib/jvm/java-6-openjdk/jre

However when I specify that directory as JAVA_HOME in Jenkins : "configure system", it returns error message saying that directory does not look like a jdk directory.

it is also failing to pick up my maven install.

Am I missing something obvious ?

like image 766
NimChimpsky Avatar asked Nov 18 '11 16:11

NimChimpsky


People also ask

Where is JAVA_HOME in Jenkins?

Your JAVA_HOME variable must be set to /usr/lib/jvm/java-6-openjdk and it must be available for the user that starts Jenkins.

How can I set JAVA_HOME path?

To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.


2 Answers

Your JAVA_HOME variable must be set to /usr/lib/jvm/java-6-openjdk and it must be available for the user that starts Jenkins.

From Kyle Strand comment:

As of April 2015 (I think), Jenkins requires Java7. Also note that the java binary path (JAVA) must be set to the correct version if the system default is still Java 6. Finally, for anyone wondering where these variables are set, it's in a config file listed with the installation instructions on the Jenkins webpage (e.g. for Debian it's /etc/default/jenkins).

like image 65
Ernesto Campohermoso Avatar answered Sep 22 '22 10:09

Ernesto Campohermoso


Using Jenkins 2 (2.3.2 in my case), the right way seems to insert the following into your pipeline file:

env.JAVA_HOME="${tool 'jdk1.8.0_111'}" env.PATH="${env.JAVA_HOME}/bin:${env.PATH}" 

"jdk1.8.0_111" beeing the name of the java configuration initially registered into Jenkins

like image 21
user1767316 Avatar answered Sep 26 '22 10:09

user1767316