Java Jre 8 Install
I Am Trying to Install Java Jre 8 on My Linux Machine (Ubuntu 14.04 (Trusty Tahr)). I've Done Two Things: the First Was Follow Java's Help Page. I Downloaded...
I am trying to install Java JRE 8 on my Linux machine (Ubuntu 14.04 (Trusty Tahr)). I've done two things:
The first was follow Java's help page. I downloaded the tarball and installed it using the tar zxvf jre-8u73-linux-x64.tar.gz command. However, when I run:
java -version
I get: bash: /usr/bin/java: No such file or directory
There are no configuration files, and the binary files in /bin/ are endless... I am not sure which I am supposed to execute. I tried to execute the java file, but that did nothing.
So, I tried to just apt-get it. These are the commands I ran:
add-apt-repository ppa:openjdk-r/ppa
apt-get update
apt-get install openjdk-8-jre
However, again, when I run java -version, it displays the same thing.
So I said screw it, let me just mkdir /usr/bin/java and try it again. I autoremoved the package, and reinstalled it. Now I just get
bash: /usr/bin/java: Is a directory when I run java -version.
How can I fix this?
3 Answers
The other responses for some weird reason did not work for me. So, to install java 1.8 (from Oracle), I alternatively ran this:
1: Add Oracle’s PPA (Personal Package Archive):
sudo add-apt-repository ppa:webupd8team/java
2: Then update your package repository
sudo apt-get update
3: Install Oracle JDK 8:
sudo apt-get install oracle-java8-installer
That got it working for me. Now, when I run java -version, I get:
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode
For more details, see this post on Medium.com.
I don't know why you're not able to install openjdk from the ppa ppa:openjdk-r/ppa, maybe it has some problems. But if you want to install the Oracle Java, after you have extracted the folder with tar zxvf jre-8u73-linux-x64.tar.gz, you have to make a symbolic link to the executable, try with sudo ln -sv /path-to-extracted-folder/bin/java /usr/local/bin/java.
Installing the Default JRE/JDK
Firstly you update the package index
sudo apt update
Next install Java Runtime Environment(JRE) type by
sudo apt-get install default-jre
And install Java Development Kit (JDk) type by
sudo apt-get install default-jdk
Installing the Oracle JDK
Add Oracle's PPA, then update your package.
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
What version you needed typing in terminal
sudo apt-get install oracle-java6/7/8/9-installer
After installed Java you Managing your Java version
sudo update-alternatives --config java
Setting the JAVA_HOME Environment Variable
sudo update-alternatives --config java
Copy the path from your preferred installation and then open /etc/environment using nano or your favorite text editor.
sudo nano /etc/environment
Add a line like this to the file (with the correct path):
JAVA_HOME="/usr/lib/jvm/java-6/7/8/9-oracle"
Save and exit the file, and reload it.
source /etc/environment
You can now test whether the environment variable has been set by executing the following command:
echo $JAVA_HOME
And type
javac --version
java --version
These commands display what version of java (the interpreter that runs Java programs) and javac (the compiler that creates them) you have installed.