Jeroen Kransen
Jeroen Kransen

Reputation: 1471

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

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.

How can I install Open JDK 7 on Arch Linux using pacman?

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.

Upvotes: 18

Views: 96189

Answers (8)

David Soroko
David Soroko

Reputation: 9096

Or you may completely skip pacman and take full control:

  • Download the tar.gz of the JDK version you need from https://adoptopenjdk.net/

  • Expand the archive: tar zxvf OpenJDKxxx.ta.gz

  • Move the JDK to /opt: sudo mv jdk-xxx /opt

  • Update the PATH:

export JAVA_HOME=/opt/jdk-xxx
export PATH=$PATH:$JAVA_HOME/bin
  • Test: 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

Upvotes: 1

Ravindu Sachintha
Ravindu Sachintha

Reputation: 141

Due to the current procedure of downloading and installing of Oracle JDK, you may not able to do that easily with linux environment. Because lots of previously supported JDK packages are not working now. if you wish to install Oracle JDK-8 on your arch-linux / manjaro machine, this gist will guide you well.

The solution will be briefly as below.

  1. First need to clone relevant JDK git to your PC.

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

  2. Now you should have a jdk8 folder in Downloads. 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.

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

  3. Now we will enter the jdk8 folder and should edit the 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

  5. Save and exit the 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

Upvotes: 0

znurgl
znurgl

Reputation: 1107

Try this:

pacman -S java7-openjdk

Upvotes: 2

Andrea Scarpino
Andrea Scarpino

Reputation: 801

Get the best mirror near you (check this list); you can even generate a new mirror list on the archlinux website. Then run # pacman -Syy; # pacman -Su; # pacman -S jdk8-openjdk (or jre8-openjdk if you only need the JRE)

Upvotes: 31

Qinsi
Qinsi

Reputation: 820

Try the following command:

pacman -S jre7-openjdk

Upvotes: 4

NauT
NauT

Reputation: 426

RB based on armv6l. checking here you can see that there is not packaged version of openjdk for armv6l.

and here is what my arch on raspi shows

   [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 ~]#

Upvotes: 1

Hantabaru
Hantabaru

Reputation: 121

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.

Upvotes: 3

Bhavik Ambani
Bhavik Ambani

Reputation: 6657

OpenJDK is a dependency on multiple Arch Linux packages so just installing Oracle’s JDK wasn’t enough.

First had to remove icedtea-web

sudo pacman -R icedtea-web

Then build Oracle JRE AUR package,

Before installing OracleJRE I had to remove openjdk6 manually and ignore dependencies:

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

Install OracleJRE

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

Build and Install JDK AUR package:

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

Logout and Login so the PATH gets updated and java is installed.

Upvotes: 3

Related Questions