Sunday, 25 September 2011

Steps to compile and Run a java program in Ubuntu Linux

Steps to run JAVA program in Ubuntu:
1. Go to Applications > Accessories > Terminal, to open terminal window.
2. Type the following in command line
gedit Welcome.java
3. Enter the code bellow in the editor.
 class Welcome
{
    public static void main (String []args)
    {
    System.out.println("Welcome to UBUNTU");
    }
}

4. Save the file and close to return to terminal window.
5. Firstly compile the code using the following command
javac Welcome.java
That would produce an class file you may need to run the program.
7. Now run this executable using the following command
java Welcome
8. Output should show as follows:
Welcome to UBUNTU

Post a Comment