无法运行命令`/opt/jdk1.8.0_131/bin/java':没有这样的文件或目录

时间:2018-07-09 17:34:18

标签: java centos6

我的服务器上安装了Java环境

java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

Java设置变量路径:

export JAVA_HOME=/opt/jdk1.8.0_171
export JRE_HOME=/opt/jdk1.8.0_171/jre
export PATH=$PATH:/opt/jdk1.8.0_171/bin:/opt/jdk1.8.0_171/jre/bin

当我运行使用Java的应用程序时,即使安装它,我仍然会收到此错误

nohup: failed to run command `/opt/jdk1.8.0_131/bin/java': No such file or directory

1 个答案:

答案 0 :(得分:1)

首先像下面那样修改.bashrc文件,您不需要JRE_HOME

export JAVA_HOME=/opt/jdk1.8.0_171
export PATH=$JAVA_HOME/bin:$PATH

这足够了,并将jdk1.8.0_171锁定为用户级别

sudo chown user:group jdk1.8.0_171

例如 sudo chown deadpool:deadpool jdk1.8.0_171 然后检查 java -v 哪个java

观察错误,查找目录 jdk1.8.0_131 ,但路径中的目录为 jdk1.8.0_171