Linux Java已安装,在列表中,但执行产生“./java:没有这样的文件或目录”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9081962/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java is installed, in listing, but execution produces "./java: No such file or directory"
提问by thejartender
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.
我刚刚运行了下面的脚本,它提取 JDK 并将其解压缩到正确的位置。问题是每个java
命令(复制到/urs/bin)都会出错。然后我通过进入 JDK 安装目录cd
(我现在在 JDK/bin 中)并输入 :./java -version
并获取 : 来仔细检查./java: No such file or directory
,但是java
在那里!ls -l
在 JDK 上显示所有java
客户端都在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
跑步ls -l /usr/lib/jvm/jdk1.7.0_02/bin/java
给了我: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 :
还运行:file /usr/lib/jvm/jdk1.7.0_02/bin
输出为:
/usr/lib/jvm/jdk1.7.0_02/bin: directory
采纳答案by Petesh
You're running on a 64bit system without a 32bit runtime environment.
您在没有 32 位运行时环境的 64 位系统上运行。
Assuming ubuntu/debian issue:
假设 ubuntu/debian 问题:
apt-get install libc6-i386
Or you should install the 64bit version of the package into this VM (which is probably the best solution).
或者您应该将 64 位版本的软件包安装到此 VM 中(这可能是最好的解决方案)。
The error message is coming from the run-time linker/loader. if you do a readelf -l java
you will find a line like:
错误消息来自运行时链接器/加载器。如果你这样做,readelf -l java
你会发现一行:
[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
.
这是您对 32 位应用程序的期望,并且您可能没有安装 32 位环境 - 检查 ls -l program interpreter
。
and example for a 64bit program would look like (your system may vary):
64 位程序的示例如下(您的系统可能会有所不同):
[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:
如果不是这种情况,并且您确实安装了 32 位 libc,则可以尝试一个ldd java
,它会给出如下列表:
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.
如果有台词,not found
那么你应该添加提供它的 pagkages,但正如你所看到的,ldd
所有的依赖项都是核心库,几乎所有的 Linux 系统都应该存在。
回答by SPLUS1
I was getting the
我得到了
bash: /usr/bin/java: No such file or directory
bash: /usr/bin/java: 没有那个文件或目录
The issue was I installed the i586
version of Java on a x86_64
Debian.
问题是我i586
在x86_64
Debian上安装了Java 版本。
The fix: I removed it and install the x64
version of Java. Everything is working fine now.
修复:我删除了它并安装了x64
Java 版本。现在一切正常。