Well I recommend you to add the following in the file /etc/profile so that the java path could be usable system-wide. JAVA_HOME and PATH variable can be set as follows : Open up a terminal
sudo nano /etc/profile
At the following statements at the bottom of the file , I am assuming your java extracted folder is at /usr/lib/jvm/java-8-oracle
JAVA_HOME=/usr/lib/jvm/java-8-oracle
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/lib/jvm/java-8-oracle/jre
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Save the file by pressing Ctrl + x y enter
Better give read and execute permission for the Java installation folder as follows :
sudo chmod -R a+rx /usr/lib/jvm/java-8-oracle
I also recommend to update alternative for all the application to use java when required as follows :
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-8-oracle/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java-8-oracle/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/java-8-oracle/bin/javaws" 1
sudo update-alternatives --set java /usr/lib/jvm/java-8-oracle/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/java-8-oracle/bin/javac
sudo update-alternatives --set javaws /usr/lib/jvm/java-8-oracle/bin/javaws
Now reload the profile file we have updated as follows in the terminal.
Note: There is a space between . and /etc/profile in the below command.
. /etc/profile
That's it