JAVA_HOME is set to an invalid directory while configuring Jenkins to compile the git project

Getting the following error in Jenkins, while compiling the code:

Error: JAVA_HOME is set to an invalid directory. JAVA_HOME = "C:\Users\admin\.jenkins\tools\hudson.model.JDK" Please set the JAVA_HOME variable in your environment to match the location of your Java installation. 

In the Environment variable, i have set the JAVA_HOME as:

C:\Program Files\Java\jdk1.8.0_45 

In Jenkins , under Build section , I have set the goal as "compile" for "Invoke top level Maven targets".

Please provide your valuable suggestions.

3

2 Answers

It appears that Jenkins when installed as a service over-rides the set JAVA_HOME system environment variable and sets itself to JRE that came with Jenkins installation. So all Java Builds fail, as this requires JDK

The solution that worked for us is, we had to configure JAVA_HOME environment variable in Manage Jenkins > Configure System > Global Properties

enter image description here

1

try to add this command in "Path" in Environment variable C:\ProgramData\Oracle\Java\javapath;%JAVA_HOME%\bin

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like