how to program in java on ubuntu 10.04

Java Programming on Ubuntu 10.04

Java is multi platform programming language.It uses JDK(includes jre) to create a class file from the source code and then the generated class file can be run on any computer by using Java Virtual Machine(JVM).So to write and execute java programs Java Development Kit(JDK) must be installed on the computer.

Installing JRE /JDK on Ubuntu 10.04 for java programming
If you have not installed the JDK yet, then first install jdk on ubuntu 10.04 and then return to this page.
When you have installed JDK successfully on ubuntu ,then you will be able to write and execute jav programs.Follow these simple steps to write and execute your first java program on ubuntu 10.04 –

How to compile and run java program on Ubuntu 10.04

1. Open Gedit OR Write click on Desktop and select Create Documents->Empty File.

2. Write this simple java code to test..

// A program to print some text.
public class Welcome
// main method begins execution of Java application
public static void main( String[] args )
System.out.println("Hello World!");
System.out.println("Welcome to Java Programming! on Ubuntu 10.04");

} // method main ends here
} // end of the class Welcome

3. Save it as “” on your Desktop(or in any other directory).
4. Now compile this java program to create the class file by using this command on terminal(CTRL+ALT+T).

$ javac

5. Now you will notice a class file “Welcome.class” on your Desktop.Now JVM will execute this code through the command given below –

$ java Welcome

6. Then the java Program will be execute by jvm and you will see the following output.
Hello World!
Welcome to Java Programming! on Ubuntu 10.04

how to program in java on ubuntu 10.04

  • Pingback: How to install Java(JDK) in Ubuntu 10.04 | Sudobits Blog | Hack to Learn()

  • Pingback: Java Programming on Ubuntu 10.04 | Sudobits Blog | Hack to Learn | java()

  • Jayakumar

    very nice

    • rkjha

      Thanks Mr. Jaya Kumar …Have Fun in programming with Java, with Ubuntu.

  • Sjoerd

    Thanks, I just started with the book “Head First Java” and I couldn’t figure out a way to open my first code.
    I just knew I wouldn’t have to manually download Sun’s (or Oracle’s) Java from the internet :)

    • rkjha

      Have Fun, Enjoy programming with Java on Ubuntu!

  • sandeep singh

    its very helpful for me because i am new to linux world, its my first time using linux based os.

  • Jklj

    Thanks a lot

  • Mohan Hitender

    useful web page

    • Shingategr

      i like yar ur intellegent my no call me ones problem 4 me 9665512074

  • Sunilk Yadav

    Very nice and helpful article.

  • Adrai75

    i hv installed jdk 1.6 from ubuntu software center n then compiled the program on desktop but it didn’t work.
    the error was……….
    The program ‘javac’ can be found in the following packages: * openjdk-6-jdk * ecj * gcj-4.4-jdk * gcj-4.3Try: sudo apt-get install
    does anybody hv any solution to this problem, also i hv not set any class path in ubuntu 10.04 as we do in windows.

    thanx in advance………….

  • Venky

    Thank you………

  • Saumya

    thank you….

  • Iac

    good work mr.human….