Created
November 25, 2016 14:58
-
-
Save emanuelhfarias/a39269d8295143477fdf2259157b8835 to your computer and use it in GitHub Desktop.
Install Oracle Java JRE on Fedora
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install Oracle Java JRE (runtime environment) on Fedora | |
# This is script is based on Fedy | |
# To change between java versions: | |
# $ alternatives --config java | |
CACHEDIR="/var/cache/java/jre" | |
if [[ "$(uname -m)" = "x86_64" ]]; then | |
ARCH="x64" | |
else | |
ARCH="x86" | |
fi | |
mkdir -p "$CACHEDIR" | |
cd "$CACHEDIR" | |
URL=$(wget $(wget "http://www.oracle.com/technetwork/java/javase/downloads/index.html" -O - | tr ' ' '\n' | grep "/technetwork/java/javase/downloads/jre8" | head -n 1 | cut -d\" -f 2 | sed -e 's/^/http:\/\/www.oracle.com/') -O - | grep "Linux ${ARCH}" | grep ".rpm" | cut -d\" -f 12 | grep -v demos | head -n 1) | |
FILE=${URL##*/} | |
wget --header "Cookie: oraclelicense=a" -c "$URL" -O "$FILE" | |
if [[ -f "$FILE" ]]; then | |
dnf -y install "$FILE" | |
else | |
exit 1 | |
fi | |
alternatives --install /usr/bin/java java /usr/java/latest/bin/java 2000000 | |
alternatives --auto java | |
if [[ "$arch" = "x86" ]]; then | |
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/lib/i386/libnpjp2.so 2000000 | |
alternatives --auto libjavaplugin.so | |
elif [[ "$arch" = "x64" ]]; then | |
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/lib/amd64/libnpjp2.so 2000000 | |
alternatives --auto libjavaplugin.so.x86_64 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment