How to install JAVA into UBUNTU

Step 1:
Type the following line into your Terminal

sudo apt-get install openjdk-6-jdk 


Step 2:
If there was some error during the installation, re-type step 1.

Step 3:
After finish your installation, type the following command
javac -version
If your java is successfully installer, you should be able to see your java version, for example,

javac 1.6.0_20

Step 4:
Create a simple java program by:
gedit testing.java

class testing {

    public
static void main (String [] args) {

        javax.swing.JFrame window;

        window
= new javax.swing.JFrame();

 

       
window.setSize(300,100);

        window.setTitle(“My
First Java Program in Lab”);

        window.setVisible(true);

    }

}

After that, back to your terminal, and type “javac ./testing.java” followed by “java testing“.
If you see a pop up, means u had successes.