java - -bash : java: command not found in Centos5

标签 java linux ubuntu centos

# java -version
-bash: java: command not found

我在 usr/local 中有 jdk1.8.0_40 这个文件夹。 当我导航到该文件夹​​并键入 alternatives --config jar 时,我得到了这样的输出

There is 1 program that provides 'jar'.

      Selection    Command
    -----------------------------------------------
    *+ 1           /opt/jdk1.8.0_40//bin/jar

    Enter to keep the current selection[+], or type selection number: 

这些是jdk中的内容

bin    include     lib      README.html  THIRDPARTYLICENSEREADME-JAVAFX.txt
COPYRIGHT  javafx-src.zip  LICENSE  release  THIRDPARTYLICENSEREADME.txt
db     jre         man      src.zip

最佳答案

您需要将安装路径添加到 PATH 变量中。 Bash 仅在您的 PATH 变量定义的路径中查找可执行文件。

关于java - -bash : java: command not found in Centos5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45372651/

相关文章:

linux - Bash:在其他脚本中运行脚本会引发错误我不会单独运行它们

Mysql 服务无法启动

linux dup2 似乎不适用于管道?

mysql - 目前 Ubuntu 上的 puppetlabs-mysql 模块有什么技巧吗?

java - 动态按钮上的事件监听器

java - 无法增加 MyEclipse 堆内存 (Xmx)

ubuntu - 如何解决 ubuntu 中 phantom js 的权限被拒绝错误?

python - 在基本操作系统(或 Ubuntu)上使用 python 3.8 而不是 3.6

java - Java中负数相减的问题

java - Solr 报告 : "Connection refused" when running import