How to install Java on Arch Linux
Asked Answered
M

8

18

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.

Muscat answered 18/11, 2012 at 11:26 Comment(3)
Does pacman -Ss openjdk find the package you're looking for?Prom
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.Muscat
which java do you need, for running software or for development? jre or jdk?Gothar
L
31

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)

Liatris answered 7/1, 2013 at 16:22 Comment(3)
+1, this is (almost) the way I would do it. One note, do NOT do pacman -Syy, use pacman -Syu. Partial upgrades are unsupported.Maddux
Correct. You should always perform an update after a -Sy (or -Syy).Liatris
You can compress all of this into # pacman -Syyu jdk8-opoenjdkMaddux
A
4

Try the following command:

pacman -S jre7-openjdk
Alger answered 6/1, 2013 at 9:33 Comment(0)
F
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.

Falda answered 18/11, 2012 at 11:32 Comment(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.Sallie
F
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.

Frimaire answered 6/12, 2012 at 8:56 Comment(0)
H
2

Try this:

pacman -S java7-openjdk
Hagio answered 18/11, 2012 at 11:30 Comment(2)
That looked encouraging, but too bad: Target not found :-(Muscat
That should actually be pacman -S jdk7-openjdk. Now you can replace the 7 with 8 or 9.Aaronaaronic
M
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 ~]#
Markel answered 13/12, 2012 at 13:35 Comment(0)
B
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

Beckon answered 28/5, 2020 at 21:59 Comment(0)
L
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

Luxembourg answered 30/7, 2019 at 9:56 Comment(2)
Please add some explanation too, as links may die one dayTwophase
Thanks for the guidance and updated an improved answer.Luxembourg

© 2022 - 2024 — McMap. All rights reserved.