> java -version
> java version '1.8.0_121'
> Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
> Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
> javac -version
javac 1.8.0_121
command not found
, you will need to install JDK before you can start writing and compiling Java programs. Choose an operating system below, and follow the instructions to get started.javac -version
). sudo apt-get purge openjdk-*
Once this is completed, the next steps should be taken to install the Java Development Kit: cd /usr/local
sudo mkdir java
cd /usr/local/java
sudo tar xzvf ~/Downloads/filename.tar.gz
Replacing filename with the name of the file you downloaded.sudo gedit /etc/profile
JAVA_HOME=/usr/local/java/jdk1.8.0_20
JRE_HOME=/usr/local/java/jre1.8.0_20
PATH=$PATH:$JRE_HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
sudo update-alternatives --install '/usr/bin/java' 'java' '/usr/local/java/jdk1.8.0_20/bin/java'
sudo update-alternatives --install '/usr/bin/javac' 'javac' '/usr/local/java/jdk1.8.0_20/bin/javac'
sudo update-alternatives --install '/usr/bin/javaws' 'javaws' '/usr/local/java/jdk1.8.0_20/bin/javaws'
sudo update-alternatives --set java /usr/local/java/jdk1.8.0_20/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_20/bin/javac
sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_20/bin/javaws
source /etc/profile
javac -version
javac -version
to check that the JDK is installed correctly.