In the introductory chapter, we decided to use Java as the programming language for the development process. For using it, we need to install Java in our system. I am providing installation steps for Windows, Linux, and MacOS. Depending on the operating system you have, follow the installation process.
Before installation, we need to download the Java for developers from the official website of Oracle. You may log on to Oracle website and navigate to the executable file for your system or just click here to the executables download page. Accept the agreement and download the one which fits your computer system.
For Android programming, you must have installed GUI version of Linux.
Open a terminal and switch to root user using command
Copy the downloaded file (current version of java is jdk1.8.0_144, change it with the version you have downloaded) in /opt folder and extract it using command
cd /opt tar xzf jdk1.8.0_144.tar.gz
now navigate to the extracted folder using the following command:
using alternatives command install and configure Java
alternatives --install /usr/bin/java java /opt/jdk1.8.0_144/bin/java 2 alternatives --config java
Select the current Java by pressing the prefix numeric key
In same way install javac and jar
alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_144/bin/jar 2 alternatives --set jar alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_144/bin/javac 2 alternatives --set javac
Check the version of Java currently active
Set the environment variable
# export JAVA_HOME=/opt/jdk1.8.0_144 # export JRE_HOME=/opt/jdk1.8.0_144/jre
configure the PATH variable for Java
# export PATH=$PATH:/opt/jdk1.8.0_144/bin:/opt/jdk1.8.0_144/jre/bin
To presist these values over system reboot, add these variables in /etc/environment file
If you get the message something like shown in the image, then Java is installed successfully. If you find any error, follow the process once again in the same sequence.
Now you have successfully installed Java, let's move further and learn how to install Android Studio.