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

19,186

Solution 1

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...

Solution 2

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
"
Share:
19,186
Jonathan Airey
Author by

Jonathan Airey

Hi, welcome to my profile!

Updated on July 25, 2022

Comments

  • Jonathan Airey
    Jonathan Airey over 1 year

    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?