Reputation: 397
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.
Upvotes: 6
Views: 13279
Reputation: 2188
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
Upvotes: 6
Reputation: 89
try to add this command in "Path" in Environment variable C:\ProgramData\Oracle\Java\javapath;%JAVA_HOME%\bin
Upvotes: 0