Tag Archives: first java program on ubuntu

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 “Welcome.java” 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 Welcome.java

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