17

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.

David Soroko
  • 8,521
  • 2
  • 39
  • 51
Jeroen Kransen
  • 1,379
  • 3
  • 19
  • 45
  • Does `pacman -Ss openjdk` find the package you're looking for? – Reactormonk Nov 18 '12 at 11:28
  • It finds one, `extra/openjdk6 6.b24_1.11.4-1`. I tried several combinations, but pacman -S openjdk6 was not one of them. It's an old version, and it seems to give me just a JRE instead of a complete JDK. – Jeroen Kransen Nov 18 '12 at 12:04
  • which java do you need, for running software or for development? jre or jdk? – Kokizzu Mar 20 '13 at 16:18

8 Answers8

30

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)

Andrea Scarpino
  • 791
  • 6
  • 13
4

Try the following command:

pacman -S jre7-openjdk
oz123
  • 27,559
  • 27
  • 125
  • 187
Qinsi
  • 780
  • 9
  • 15
3

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.

Bhavik Ambani
  • 6,557
  • 14
  • 55
  • 86
  • 1
    Please do not advise users to install unofficial packages right away while the piece of software OP is looking for is available in an official repo. OP should maybe just refresh the package lists first `pacman -Sy`. Answer from ilpianista is the correct one. – galaux Mar 01 '16 at 21:15
3

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.

Hantabaru
  • 111
  • 8
2

Try this:

pacman -S java7-openjdk
Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225
znurgl
  • 1,077
  • 7
  • 12
1

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 ~]#
NauT
  • 396
  • 2
  • 7
1

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

David Soroko
  • 8,521
  • 2
  • 39
  • 51
0

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

Community
  • 1
  • 1