Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting Jenkins bash: /usr/bin/java: No such file or directory

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?

like image 552
Jonathan Airey Avatar asked Nov 17 '13 13:11

Jonathan Airey


2 Answers

Jenkins needs java to start and in your case in /usr/bin/ directory java 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
"
like image 167
Zeeshan Avatar answered Nov 14 '22 01:11

Zeeshan


Try fix it by using:

ln -s /opt/jdk/bin/java /usr/bin/java

The script file who service utility is using is probably /etc/init.d/jenkins You could edit this file too...

like image 32
saulotoledo Avatar answered Nov 13 '22 23:11

saulotoledo