Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java is installed, in listing, but execution produces "./java: No such file or directory"

Tags:

java

linux

ubuntu

I just ran the script below and it fetches and unpacks the JDK into the correct location. Problem is that every java command (as copied to /urs/bin) gives errors. I then double check by going into the JDK install directory by means of cd (I am now in JDK/bin) and type : ./java -version and get : ./java: No such file or directory, but java is there! ls -l on the JDK shows that all java clients are inside the bin.

#!/bin/bash
#Author: Yucca Nel http://thejarbar.org
#Will restart system
#Modify these variables as needed...
tempWork=/tmp/work
locBin=/usr/local/bin
javaUsrLib=/usr/lib/jvm

sudo mkdir -p $javaUsrLib
mkdir -p $tempWork
cd $tempWork

#Update this line to reflect newer versions of JDK...
wget http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-i586.tar.gz

#Extract the download
tar -zxvf $tempWork/*

#Move it to where it can be found...

sudo mv -f $tempWork/jdk1.7* $javaUsrLib/

sudo ln -f -s $javaUsrLib/jdk1.7*/bin/* /usr/bin/
sudo rm -rf $tempWork
#Update this line to reflect newer versions of JDK...
export JAVA_HOME="$javaUsrLib/jdk1.7.0_02"

if ! grep "JAVA_HOME=$javaUsrLib/jdk1.7.0_02" /etc/environment
then
    echo "JAVA_HOME=$javaUsrLib/jdk1.7.0_02"| sudo tee -a /etc/environment
fi

sudo /sbin/reboot

exit 0

Running ls -l /usr/lib/jvm/jdk1.7.0_02/bin/java gives me : yucca@yucca-VirtualBox:~$ -rwxr-xr-x 1 yucca yucca 5654 2011-11-17 22:38 /usr/lib/jvm/jdk1.7.0_02/bin/java

also ran: file /usr/lib/jvm/jdk1.7.0_02/bin with an output of :

/usr/lib/jvm/jdk1.7.0_02/bin: directory
like image 549
thejartender Avatar asked Jan 31 '12 15:01

thejartender


1 Answers

You're running on a 64bit system without a 32bit runtime environment.

Assuming ubuntu/debian issue:

apt-get install libc6-i386

Or you should install the 64bit version of the package into this VM (which is probably the best solution).

The error message is coming from the run-time linker/loader. if you do a readelf -l java you will find a line like:

 [Requesting program interpreter: /lib/ld-linux.so.2]

Which is what you expect for a 32bit application, and you probably don't have the 32bit environment installed - check with an ls -l of that program interpreter.

and example for a 64bit program would look like (your system may vary):

 [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]

If this is not the case, and you do have the 32bit libc installed, you can try an ldd java, which will give a listing like:

linux-gate.so.1 =>  (0xf76ef000)
libpthread.so.0 => /lib32/libpthread.so.0 (0xf76b3000)
libjli.so => /home/bubba/java/jdk1.7.0_02/bin/./../jre/lib/i386/jli/libjli.so (0xf769f000)
libdl.so.2 => /lib32/libdl.so.2 (0xf7699000)
libc.so.6 => /lib32/libc.so.6 (0xf751f000)
/lib/ld-linux.so.2 (0xf76f0000)

if there are lines saying not found then you should add pagkages providing that, but as you can see from this ldd all the dependencies are core libraries that should be present on practically all linux systems.

like image 147
Petesh Avatar answered Nov 15 '22 16:11

Petesh