Java Not Found

2 minute read Modified:

./java: No such file or directory

After a Debian upgrade from squeeze (via wheezy) to jessie, I got the following message when I tried to start tomcat on the machine:

/vol/www/tomcat/bin/catalina.sh: 1: eval: /usr/local/java7/bin/java: not found

To see what the problem was, I tried different things.

client-prd-web2:/vol/www/tomcat/logs# cd /usr/local/java7/bin
client-prd-web2:/usr/local/java7/bin# strace ./java -version
execve("./java", ["./java", "-version"], [/* 15 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
exit_group(1)                           = ?
+++ exited with 1 +++
client-prd-web2:/usr/local/java7/bin# ls -l ./java
-rwxr-xr-x 1 uucp 143 5714 May  7  2014 ./java
client-prd-web2:/usr/local/java7/bin# vim test.sh
client-prd-web2:/usr/local/java7/bin# chmod a+x test.sh
client-prd-web2:/usr/local/java7/bin# ./test.sh
hello world!
client-prd-web2:/usr/local/java7/bin# rm test.sh
client-prd-web2:/usr/local/java7/bin# ./java -version
-su: ./java: No such file or directory
client-prd-web2:/usr/local/java7/bin#

The file was on the right place and I could start an executable from that directory, but executing java still gave the same error.

client-prd-web2:/usr/local/java7/bin# file java
java: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, 
interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.9, 
BuildID[sha1]=3f324968e275755244b6a10609e81796be828e15, not stripped
client-prd-web2:/usr/local/java7/bin# ldd java
        not a dynamic executable
client-prd-web2:/usr/local/java7/bin# 

I thought it strange the file said it was dynamically linked, but ldd said otherwise. So I checked on the acceptance machine and there file gave the same result, but ldd showed libs in /lib32.

i386 executable

With the information that the acceptance version linked to a /lib32 library, I checked the production server for those libs.

client-prd-web2:/usr/local/java7/bin# ls /lib32
ls: cannot access /lib32: No such file or directory
client-prd-web2:/usr/local/java7/bin# apt-get install libc6-i386
....
client-prd-web2:/usr/local/java7/bin# ./java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) Client VM (build 24.60-b09, mixed mode)
client-prd-web2:/usr/local/java7/bin# ldd ./java
        linux-gate.so.1 (0xf770e000)
        libpthread.so.0 => /lib32/libpthread.so.0 (0xf76e9000)
        libjli.so => /var/usr/local/jdk1.7.0_60/bin/./../lib/i386/jli/libjli.so (0xf76d5000)
        libdl.so.2 => /lib32/libdl.so.2 (0xf76d0000)
        libc.so.6 => /lib32/libc.so.6 (0xf7523000)
        /lib/ld-linux.so.2 (0xf7711000)
client-prd-web2:/usr/local/java7/bin#

That directory was not available, so I installed libc6-i386 and java was working again. Of course it would be better to use a 64-bit java version, but because there was already a lot of changes on the system I didn’t want to add this to the list.

Recent posts
- full list -