I have a CentOS server and I'm trying to run jenkins as a service with:
service jenkins start
I am running as root
user and I'm getting this response:
Starting Jenkins bash: /usr/bin/java: No such file or directory
[FAILED]
I have echo
'ed a few things to the command line:
[root@xyz opt]# echo $JAVA_HOME
/opt/jdk
[root@xyz opt]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin:/opt/jdk/bin:/opt/grails/bin
[root@xyz opt]# java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
[root@xyz opt]# which java
/opt/jdk/bin/java
I cannot see any java configuration in any jenkins files. Any ideas?
Jenkins needs java to start and in your case in
/usr/bin/
directoryjava
is not available
If you go to /etc/init.d/
and open jenkins
file you will find:
candidates="
/etc/alternatives/java
/usr/lib/jvm/java-1.6.0/bin/java
/usr/lib/jvm/jre-1.6.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/bin/java
"
These are the paths where jenkins looks for java, and in your case java was not present in any of the above paths.
So look for the path where you are having java and add that path in the above jenkins file.
Since you are having java in /opt/jdk/bin
, then add this in jenkins
file:
candidates="
/opt/jdk/bin/java <----Add here
/etc/alternatives/java
/usr/lib/jvm/java-1.6.0/bin/java
/usr/lib/jvm/jre-1.6.0/bin/java
/usr/lib/jvm/java-1.7.0/bin/java
/usr/lib/jvm/jre-1.7.0/bin/java
/usr/lib/jvm/java-1.8.0/bin/java
/usr/lib/jvm/jre-1.8.0/bin/java
/usr/bin/java
"