gpt4 book ai didi

java - 尝试 "apt install openjdk-8-jre-headless"和 "apt install openjdk-8-jdk"java 后不可用

转载 作者:行者123 更新时间:2023-12-02 09:57:12 26 4
gpt4 key购买 nike

我尝试安装支持 Java 11 的最新稳定 Jenkins 版本。因此,在安装 Java 11(JDK) 后,我收到 Jenkins 的错误,指出发现了不正确的 java 版本。

因此卸载了 Java 11 并尝试安装 Java 8。在安装 java 8 时,Jenkins 消息“发现错误的 java 版本”反复出现。因此,我完全删除了 Java 11(JDK) 和 Java 8(JDK),并确保/usr/bin 和/usr/lib/jvm 中没有 java 11 和 java 8 的文件夹。当我安装 java 8 时,系统说 JDK 8 已安装,但我无法在我的系统中找到任何 java 版本。为什么?

我尝试了 sudo apt install openjdk-8-jre-headlesssudo apt install openjdk-8-jdk 但 java 不在/usr/bin 中并且/usr/lib/jvm 有 java8jdk 但 bin 文件夹中没有 java。请参阅下面的命令和控制台输出。

sudo apt install openjdk-8-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
daemon net-tools
Use 'sudo apt autoremove' to remove them.
Suggested packages: openjdk-8-demo openjdk-8-source visualvm
The following NEW packages will be installed
openjdk-8-jdk
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 0 B/1,435 kB of archives. After this operation, 1,538 kB of additional disk space will be used.
Selecting previously unselected package openjdk-8-jdk:amd64. (Reading database ... 168837 files and directories currently installed.)
Preparing to unpack .../openjdk-8-jdk_8u191-b12-2ubuntu0.18.04.1_amd64.deb ...
Unpacking openjdk-8-jdk:amd64 (8u191-b12-2ubuntu0.18.04.1) ...
Setting up openjdk-8-jdk:amd64 (8u191-b12-2ubuntu0.18.04.1) ..
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/appletviewer to provide /usr/bin/appletviewer (appletviewer) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jconsole to provide /usr/bin/jconsole (jconsole) in auto mode

当我尝试 openjdk-jre-headless 时,我得到了以下内容

sudo apt install openjdk-8-jre-headless
Reading package lists... Done
Building dependency tree Reading state information... Done
openjdk-8-jre-headless is already the newest version (8u191-b12-2ubuntu0.18.04.1).
The following packages were automatically installed and are no longer required:
daemon libice-dev libpthread-stubs0-dev libsm-dev libx11-dev libx11-doc libxau-dev libxcb1-dev libxdmcp-dev libxt-dev net-tools openjdk-8-jdk-headless x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev
Use 'sudo apt autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded

还是没用。我找不到java。 which java 不返回任何内容。 java -version 返回以下.... 未找到命令“java”,但可以使用以下命令安装: sudo apt install default-jre sudo apt install openjdk-11-jre-headless sudo apt安装openjdk-8-jre-headless

有人可以帮我解决这个问题吗?如何正确安装java?删除/卸载 Jenkins 后,我还尝试安装 java 但没有用。我之前安装的 jenkins 是否会阻止任何 java 安装?

最佳答案

您是否尝试过将 Java 添加到环境变量中?

  1. 检查您安装的 Java 版本并选择所需的版本sudo update-alternatives --config java

  2. 将 Java 路径导出为环境变量导出 PATH=$PATH:/usr/java/jrex.x.x_xxx/bin/

  3. 将此行添加到您的主目录中的 .bashrc 文件中。这将在打开 bash 时更新您的环境变量

也许this answer可以帮助你。

关于java - 尝试 "apt install openjdk-8-jre-headless"和 "apt install openjdk-8-jdk"java 后不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55914998/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com