简体   繁体   English

如何在 Arch Linux 上安装 Java

[英]How to install Java on Arch Linux

According to https://wiki.archlinux.org/index.php/Java I can install Open JDK 7 on a clean Arch Linux installation by invoking the command根据https://wiki.archlinux.org/index.php/Java我可以通过调用命令在干净的 Arch Linux 安装上安装 Open JDK 7

pacman -S jdk7-openjdk

But when doing so, I get an error saying但是这样做时,我收到一条错误消息

error: target not found: jdk7-openjdk

I already commented out my nearest Pacman repository in /etc/pacman.d/mirrorlist and ran a first update by invoking pacman -Syu hoping that this would cause the package above to be discovered.我已经在/etc/pacman.d/mirrorlist注释了离我最近的 Pacman 存储库,并通过调用 pacman -Syu 运行了第一次更新,希望这会导致上面的包被发现。

How can I install Open JDK 7 on Arch Linux using pacman?如何使用 pacman 在 Arch Linux 上安装 Open JDK 7?

Edit: I'm running a Raspberry Pi with an ARM processor and I'm hoping to get a Java build that is tailored for its hardware and uses the OS hardware floating point support.编辑:我正在运行带有 ARM 处理器的 Raspberry Pi,我希望获得一个为其硬件量身定制的 Java 版本,并使用操作系统硬件浮点支持。

Get the best mirror near you (check this list );获取您附近最好的镜子(查看此列表); you can even generate a new mirror list on the archlinux website .你甚至可以在archlinux 网站上生成一个新的镜像列表。 Then run # pacman -Syy; # pacman -Su; # pacman -S jdk8-openjdk然后运行# pacman -Syy; # pacman -Su; # pacman -S jdk8-openjdk # pacman -Syy; # pacman -Su; # pacman -S jdk8-openjdk # pacman -Syy; # pacman -Su; # pacman -S jdk8-openjdk (or jre8-openjdk if you only need the JRE) # pacman -Syy; # pacman -Su; # pacman -S jdk8-openjdk (如果您只需要 JRE,则使用jre8-openjdk

尝试以下命令:

pacman -S jre7-openjdk

OpenJDK is a dependency on multiple Arch Linux packages so just installing Oracle's JDK wasn't enough. OpenJDK 依赖于多个 Arch Linux 软件包,因此仅安装 Oracle 的 JDK 是不够的。

First had to remove icedtea-web首先必须删除 icedtea-web

sudo pacman -R icedtea-web

Then build Oracle JRE AUR package,然后构建 Oracle JRE AUR 包,

Before installing OracleJRE I had to remove openjdk6 manually and ignore dependencies:在安装 OracleJRE 之前,我必须手动删除 openjdk6 并忽略依赖项:

[argy@Freak jre]$ sudo pacman -Rdd openjdk6

Install OracleJRE安装 OracleJRE

sudo pacman -U jre-7u2-1-i686.pkg.tar.xz

Build and Install JDK AUR package:构建和安装 JDK AUR 包:

sudo pacman -U jdk-7u2-1-i686.pkg.tar.xz

Logout and Login so the PATH gets updated and java is installed.注销并登录,以便更新 PATH 并安装 java。

Just a quick observation:只是一个快速的观察:

When you change your repository it is a good idea to update using pacman -Syyu as this will refresh all the packages.当您更改存储库时,最好使用pacman -Syyu进行更新,因为这将刷新所有软件包。

尝试这个:

pacman -S java7-openjdk

RB based on armv6l.基于 armv6l 的 RB。 checking here you can see that there is not packaged version of openjdk for armv6l.检查这里你可以看到没有为 armv6l 打包的 openjdk 版本。

and here is what my arch on raspi shows这是我在 raspi 上的拱门显示的内容

   [root@raspi ~]# pacman -Ss openjdk
    extra/openjdk6 6.b24_1.11.4-1
    Free Java environment based on OpenJDK 6.0 with IcedTea6 replacing binary plugs.
   [root@raspi ~]#

Or you may completely skip pacman and take full control:或者你可以完全跳过吃pacman并完全控制:

  • Download the tar.gz of the JDK version you need from https://adoptopenjdk.net/https://adoptopenjdk.net/下载你需要的JDK版本的tar.gz

  • Expand the archive: tar zxvf OpenJDKxxx.ta.gz展开存档: tar zxvf OpenJDKxxx.ta.gz

  • Move the JDK to /opt : sudo mv jdk-xxx /opt将 JDK 移动到/optsudo mv jdk-xxx /opt

  • Update the PATH :更新PATH

export JAVA_HOME=/opt/jdk-xxx
export PATH=$PATH:$JAVA_HOME/bin
  • Test: java -version测试: java -version

This way you can install as many different versions of the JDK you want and switch between them by changing the value of PATH通过这种方式,您可以安装任意多个不同版本的 JDK,并通过更改PATH的值在它们之间进行切换

Due to the current procedure of downloading and installing of Oracle JDK, you may not able to do that easily with linux environment.由于当前下载和安装 Oracle JDK 的过程,您可能无法在 linux 环境下轻松完成。 Because lots of previously supported JDK packages are not working now.因为许多以前支持的 JDK 包现在都不起作用了。 if you wish to install Oracle JDK-8 on your arch-linux / manjaro machine, this gist will guide you well.如果你想在你的arch-linux / manjaro机器上安装Oracle JDK-8这个要点会很好地指导你。

The solution will be briefly as below.解决方法简述如下。

  1. First need to clone relevant JDK git to your PC.首先需要将相关的 JDK git 克隆到您的 PC。

    cd ~/Downloads && git clone https://aur.archlinux.org/jdk8.git

  2. Now you should have a jdk8 folder in Downloads.现在您应该在下载中有一个 jdk8 文件夹。 Move that ".tar.gz" which you downloaded from oracle to that folder, If it is also in downloads, and I got the filename right, the command would be like this.将您从 oracle 下载的“.tar.gz”移动到该文件夹​​,如果它也在下载中,并且我的文件名正确,则命令将是这样的。

    mv ~/Downloads/jdk-8u212-linux-x64.tar.gz ~/Downloads/jdk8/

  3. Now we will enter the jdk8 folder and should edit the PKGBUILD.现在我们将进入 jdk8 文件夹并编辑 PKGBUILD。

    cd jdk8 && nano PKGBUILD

  4. The source line we want to change from is.... "https://download.oracle.com/otn-pub/java/jdk/${pkgver}-${_build}/${_hash}/${_pkgname}-${pkgver}-linux-x64.tar.gz" to the filename we now have in folder, jdk-8u212-linux-x64.tar.gz我们要更改的源代码是.... "https://download.oracle.com/otn-pub/java/jdk/${pkgver}-${_build}/${_hash}/${_pkgname}-${pkgver}-linux-x64.tar.gz"到我们现在在文件夹jdk-8u212-linux-x64.tar.gz中的文件名

  5. Save and exit the PKGBUILD.保存并退出 PKGBUILD。 Now we can build and install from within that directory.现在我们可以从该目录中构建和安装。

    makepkg -sric

  6. If everything looks like it went fine you can just remove that directory when you are done.如果一切正常,您可以在完成后删除该目录。

    cd ~ && rm -r ~/Downloads/jdk8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM