How to Install Oracle Java on Ubuntu Linux? Java Performance Problems
Main reason of this problem is the installation of OpenJRE/JDK instead of OracleJRE/JDK
• Start by learning your java version by typing
java -version
• If you have OpenJDK installed on your system, you got something like this
java version "1.6.0_21" OpenJDK Runtime Environment (IcedTea6 1.10pre) (6b21~pre1-0lucid1) OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
• Remove JDK and JRE by typing
sudo apt-get autoremove openjdk-6-jre
sudo apt-get autoremove openjdk-6-jdk
• Create a folder for new Java installation
sudo mkdir -p /usr/local/java
• Download Oracle JRE and/or JDK from http://www.oracle.com/ as TAR.GZ file
• Copy downloaded files into Java installation folder
sudo cp jdk-7-linux-x64.tar.gz /usr/local/java cd /usr/local/java
• Open compressed files into this directory
sudo chmod a+x jdk-7-linux-x64.tar.gz tar xvzf jdk-7-linux-x64.tar.gz
• Edit /etc/profile to change system path
sudo gedit /etc/profile
• Go to the end of the file and add similar lines for your java version, then save and exit.
JAVA_HOME=/usr/local/java/jdk1.7.0 PATH=$PATH:$HOME/bin:$JAVA_HOME/bin JAVA_HOME=/usr/local/java/jre1.7.0 PATH=$PATH:$HOME/bin:$JAVA_HOME/bin export JAVA_HOME export PATH
• Inform Ubuntu system about JDK/JRE location
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.7.0/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.7.0/bin/javac" 1
• Inform Ubuntu system about default JDK/JRE
sudo update-alternatives --set java /usr/local/java/jre1.7.0/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.7.0/bin/javac
• Reload your profile information
. /etc/profile
• Check your Java version again
javac -version