To install JDK on Ubuntu we need to do several step. Basically this tutorial for 32-bit and 64-bit Oracle Java 8 JDK on 32-bit and 64-bit Ubuntu operating systems. These instructions will also work on Debian and Linux Mint
1. Go to terminal and type /sbin/init, this command to check your Ubuntu architecture weather it's 32 or 64 bit.
2. Check Java installed, type java-version on your terminal. If you have OpenJDK installed on your system it will give this results:
- java version "1.7.0_60"
OpenJDK Runtime Environment (IcedTea6 1.10pre) (7b15~pre1-0lucid1)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
3. Remove OpenJDK/JRE from your system by running this command: sudo apt-get purge openjdk-\*
4. Download JDK from Download JDK .Please Remember to download JDK version which fits with your architecture system. For example, if your system running on 32 Bit download 32 Bit Oracle Java binaries.
5.After finished download the JDK file, copy your JDK file to '/usr/local/java'.
sudo cp -r your-java-binaries /usr/local/java/
6.Go to '/usr/local/java/'. cd /usr/local/java/
7. Unpack The Java Binaries in /usr/local/java. Type sudo tar your-java-binaries
8. Your java/ folder will contain jdk and jre directory.
9. Edit system path file.
- sudo gedit /etc/profile
- Scroll down until end of file and type:
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH
- Save and exit
- sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/your-jdk-directory/bin/java" 1
- sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/your-jdk-directory/bin/javac" 1
- sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/your-jdk-directory/bin/javaws" 1
- sudo update-alternatives --set java /usr/local/java/your-jdk-directory/bin/java
- sudo update-alternatives --set javac /usr/local/java/your-jdk-directory/bin/javac
- sudo update-alternatives --set javaws /usr/local/java/your-jdk-directory/bin/javaws
13. Test by run java -version
- If your instalation is correct, in terminal will displaying something like this:
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) Server VM (build 24.51-b03, mixed mode)
14. Test your javac by run javac -version
- You should receive a message which displaying something like this: javac 1.8.0_05