Method 1
Step 1: download jdk from: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Step 2 : go to downloaded folder using command line terminal :
cd ~/Download
Step 3: install jdk
sudo tar -xzvf jdk-7u21-linux-i586.tar.gz --directory=/usr/local/ sudo ln -s /usr/local/[jdk_folder_name]/ /usr/local/jdk
* change the folder name according to extracted jdk folder name,
Step 4: open .bashrc
sudo gedit .bashrc
Step 5: add following line end of the .bashrc file
export JAVA_HOME=/usr/local/jdk
Save and close .bashrc file.
Step 6: compile .bashrc file
source .bashrc
Step 7: now test whether java is installed properly or not: goto terminal and time following line
java -version
if java is installed properly, java runtime information will be displayed.
if not… follow second method:
Method 2:
Step 1: Preparing your system
First you need to remove openjdk for this run the following command from your terminal
sudo apt-get purge openjdk*
Step 2: If you installed java 7 from any other PPA and you are having problem with java then you have to do following steps before installing the PPA mentioned here
sudo rm /var/lib/dpkg/info/oracle-java7-installer* sudo apt-get purge oracle-java7-installer* sudo rm /etc/apt/sources.list.d/*java* sudo apt-get update
Step 3: Install oracle java 7 in ubuntu 13.04/12.10/12.04
Open the terminal and run the following commands
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java7-installer
now give a smile 🙂 🙂 😀