[Solved] Installing Oracle Java

Message
Author
User avatar
fehlix
Developer
Posts: 10366
Joined: Wed Apr 11, 2018 5:09 pm

Re: Installing Oracle Java

#11 Post by fehlix »

ronjnk wrote: Wed Dec 26, 2018 7:34 pm Thanks Richard and Stevo for your input. I was aware MX did not support apt add repository directly.

Fehlix... I've heard of scripts but have never used one, so it makes more sense on why I was initially confused on all the text. I still feel like a bonehead though since I can't even save the script yet.

You are correct that I have JRE jre-8u191-linux-x64.tar.gz sitting in my downloads folder which is /home/bushguy/Downloads.

I am assuming that the whole text file is the script so I have selected all, copied and pasted the entire text you provided in featherpad. Now I want to save that text in featherpad by saving the text file directly into my Downloads folder which is where the Java file is.
E.g. save in your Download folder as : ~/Download/my_manual_install_oracle_jre.sh
I am trying to name the file ~/Download/my_manual_install_oracle_jre.sh , when I name the file exactly as I have it shown and try to save it to the Downloads folder, I get an error message "The folder contents could not be displayed. Error when getting information for file "home/bushguy/Download": No such file or directory".

I also tried saving as: ~/bushguy/Download/my_manual_install_oracle_jre.sh That failed as well with essentially the same message.

It's not my intent to drive you and the other forum pros nuts. :bagoverhead: Honest. This is not as easy as I thought it would be to get JAVA installed. Thanks. Ron
my bad I missed th "s" at the end:
and "~/Downloads" is a common abbriavation
for "$HOME/Downloads" which is also a "bash"ism for
your own Downloads-folder : /home/bushguy/Downloads
So in your case save this file within your Downloads-Folder as my_manual_install_oracle_jre.sh
or with the whole path as : /home/bushguy/Downloads/my_manual_install_oracle_jre.sh.
Than open Thunar File manager and right-click open Terminal here as normal user - not as root!
(try to avoid root terminal as much as possible - this is for experts only =) ... :snail: ...
On the command line type
chmod +x my_manual_install_oracle_jre.sh
You can abbriavte typing by just type the first two or three letter and than press tab-key,
it fill auto-complete the filename in the current folder.
...
:puppy:
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

ronjnk
Posts: 79
Joined: Wed Dec 19, 2018 9:36 pm

Re: Installing Oracle Java

#12 Post by ronjnk »

My bad too Fehlix. I thought it was a syntax error but I focused too hard and missed the obvious dropped "s".

I not only have Java installed, but my other piece of software is now installed and all is operational. I cannot thank you enough for your help. I have some tweaking to do to the system and basic linux programs to install from the MX installer and I couldn't be happier. You did an outstanding job with the script.

If you don't mind, I will do another summary in the next day or so to tidy up our exchanges and then it will be clear for others as well as for me. Then I'll copy those instructions and save them on my machine for the future. At that time, I will also mark this topic solved.

All the best Fehlix! Ron

PS. - I've taken the bag off my head. 9_9

User avatar
fehlix
Developer
Posts: 10366
Joined: Wed Apr 11, 2018 5:09 pm

Re: Installing Oracle Java

#13 Post by fehlix »

ronjnk wrote: Wed Dec 26, 2018 9:12 pm I thought it was a syntax error but I focused too hard and missed the obvious dropped "s".
Great that it helped you, it was actualy only a little script I'm using as some of my tools also prefere to use oracle jre.
Might be I can update the script to avoid the unesseray warnings when updating the alternatives.
:puppy:
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

ronjnk
Posts: 79
Joined: Wed Dec 19, 2018 9:36 pm

Re: Installing Oracle Java

#14 Post by ronjnk »

I'd like to summarize how I installed Java JRE on my MX 18. All code and instructions are courtesy of fehlix. This method should work for any debian based linux.

I downloaded the current Java JRE tar.gz file for linux from the Java website. https://www.java.com/en/download/manual.jsp That file was downloaded to my Downloads folder.

Then the entire following script was copied and pasted into featherpad.

Code: Select all

#!/bin/bash

# fehlix : my_manual_install_oracle_jre.sh
#

if [ $# != 1 ]
then
	echo "Usage $0 <JAVA-TAR.GZ-file (jre-VER-linux-ARCH.tar.gz)>"
	exit 1
fi

JAVATAR="$1"

BASENAME=${JAVATAR##*/}

echo $BASENAME
	
ARCH="$(uname -m)"
case $(uname -m) in
	x86_64) ARCH=x64 
	;;
	i386|i586|i686 ) ARCH=i586
	;;
	*)	echo "Architecture >> $(uname -m) << unknown!"
	;;
esac

echo "Architecture found: $ARCH"

if [ "$BASENAME" = "${BASENAME%%${ARCH}*}" ]
then 
	echo "Wrong Architecture JRE-File $JAVATAR"
	exit 1
else
	echo "OK: Architecture '$ARCH' match JRE-File $JAVATAR"
	
fi
if [ ! -f "$JAVATAR" ]
then
	echo "File not found:  $JAVATAR"
	exit 1
else 
	JAVATAR="$(readlink -f $JAVATAR)"
	echo "OK absolute path: JAVATAR=$JAVATAR"
fi


sudo -v
sudo whoami

sudo mkdir -p /opt/oracle_java/
cd /opt/oracle_java/
JAVADIR=$(tar --exclude="*/*" -tzf $JAVATAR) 
JAVADIR=${JAVADIR%/}
set -x
[ -d /opt/oracle_java/$JAVADIR ] && sudo rm -r  "/opt/oracle_java/$JAVADIR"

JAVAPRIOR=$(echo "$JAVADIR" | sed -E 's/[^0-9]//g')

set +x
cd /opt/oracle_java/
sudo tar --no-same-owner -xzvf "$JAVATAR"

set -x
cd /opt/oracle_java/
echo sudo ln -fns $JAVADIR java_latest
sudo ln -fns $JAVADIR java_latest

#############################
# Alternativen nur erneuern falls bereits 
# java-Alternativen vorhanden
# Ansonsten beenden!
update-alternatives --get-selections | grep -q "^java" || {
		echo "EXIT: Kein Java-Alternativen vorhanden:"
		echo "EXIT: Java-ALternativen werden nicht angelegt"
		exit
	}
# 
#############################
# Java-Alternativen erneuern/anlegen
#########################
set -x
cd /opt/oracle_java/$JAVADIR/bin;
set +x 
#
for f in *; 
do 
	test -L $f || {
		echo sudo update-alternatives --install /usr/bin/$f $f $PWD/$f $JAVAPRIOR 
		sudo update-alternatives --install /usr/bin/$f $f $PWD/$f $JAVAPRIOR 
		echo sudo update-alternatives --set $f $PWD/$f 
		sudo update-alternatives --set $f $PWD/$f 
		} ; 

done

#############################
# nun noch jexec aus lib
#############################
set +x 
cd /opt/oracle_java/$JAVADIR/lib;
for f in jexec; 
do 
	test -L $f || {
		echo sudo update-alternatives --install /usr/bin/$f $f $PWD/$f $JAVAPRIOR 
		sudo update-alternatives --install /usr/bin/$f $f $PWD/$f $JAVAPRIOR 
		echo sudo update-alternatives --set $f $PWD/$f 
		sudo update-alternatives --set $f $PWD/$f 
		} ; 

done

#############################
#############################
# OK nun die MAN-Pages Slaves:
##############################

cd /opt/oracle_java/$JAVADIR/man/man1
sudo gzip *.1
for M in *.1.gz ; 
do 
	F=${M%.1.gz} ;  
	test -f ../../bin/$F && {
		echo sudo update-alternatives --install /usr/bin/$F $F /opt/oracle_java/$JAVADIR/bin/$F $JAVAPRIOR --slave /usr/share/man/man1/$M $M $PWD/$M 
		sudo update-alternatives --install /usr/bin/$F $F /opt/oracle_java/$JAVADIR/bin/$F $JAVAPRIOR --slave /usr/share/man/man1/$M $M $PWD/$M 
	}
done

##############################
echo '#######################################'
echo EXIT
echo Will not install mozilla java plugin !!
echo '#######################################'

exit
##############################

# Manuellen Setzen der Alternative.

# Überprüfen mit:
# update-alternatives --get-selections | egrep -i "java|jdk|icedtea" 


case $ARCH in
	i586)
	#32-Bit:
		sudo update-alternatives --install "/usr/lib/mozilla/plugins/mozilla-javaplugin.so" "mozilla-javaplugin.so" "/opt/oracle_java/$JAVADIR/lib/i386/libnpjp2.so" $JAVAPRIOR
		sudo update-alternatives --set  mozilla-javaplugin.so /opt/oracle_java/$JAVADIR/lib/i386/libnpjp2.so
		;;
	x64)
	#64-Bit:
		sudo update-alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so /opt/oracle_java/$JAVADIR/lib/amd64/libnpjp2.so  $JAVAPRIOR
		sudo update-alternatives --set mozilla-javaplugin.so /opt/oracle_java/$JAVADIR/lib/amd64/libnpjp2.so 
		;;
	*)	echo "Kenne Architecture >> $(uname -m) << nicht!"
		exit 1
	;;
esac

##############################
exit
##############################
Name the file

Code: Select all

my_manual_install_oracle_jre.sh
and save it in the Downloads folder.

Go to the Downloads folder, Then open Thunar File manager by right-clicking and select open Terminal here as normal user - not as root! (try to avoid root terminal as much as possible - this is for experts only).

On the terminal command line type

Code: Select all

chmod +x my_manual_install_oracle_jre.sh
You can abbreviate typing by just typing the first two or three letters of the file name (for example my_m) and than press tab-key, it will auto-complete the filename in the current folder.

Then run the script by typing:

Code: Select all

./my_manual_install_oracle_jre.sh jre-8u191-linux-x64.tar.gz
(Remember to change the version number if different than shown. The current file is jre-8u191)

The script will automatically run and install Java. You can check that it is installed by typing in the terminal: java -version The results should match the Java version number.

My thanks to fehlix for providing this slick way to install Java.

cheapybob
Posts: 43
Joined: Tue Nov 15, 2016 2:28 am

Re: [Solved] Installing Oracle Java

#15 Post by cheapybob »

I installed this today onto antiX 19.2_x64.

The only issue I had was that the openjdk package needs to be installed first for this to work.

Thanks for providing the code and instructions. :number1:
Too many years to remember and too many computers to list.
Daily Driver: 2017 Dell XPS-15-7559 I7 16gb with 500gb SSD + 1TB HD. 4K Optimus Video, 15" 4K laptop screen + 42" Roku 4K

User avatar
fehlix
Developer
Posts: 10366
Joined: Wed Apr 11, 2018 5:09 pm

Re: [Solved] Installing Oracle Java

#16 Post by fehlix »

cheapybob wrote: Wed Aug 26, 2020 5:56 pm The only issue I had was that the openjdk package needs to be installed first for this to work.
Yes, that was a un-spoken pre-requisite, at least I haven't prepared one which does not already had openjdk installed ...
but it's never to late. Cool , you found it and made it. :happy:
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

Post Reply

Return to “Software / Configuration”