ARTICLESCLOUD.COM
FOR FREE LEARNING SESSIONS - HOW LAPTOPS WORK - FEEDBACK
 

Java Programming

Java programming involves the following steps:

1. Creating codes

2. Compiling codes to generate bytecode

3. Running the bytecode in Java platform

Your First Java Program could be as follows:


public class MyProgram {
    public static void main(String[] args) {
        System.out.println("My Program");
    }
}

In order to complile and run the above program follow the steps given below:

Creating Codes

Create the following code and save the file in Java Bin Directory giving the file name as MyProgram.java

public class MyProgram {
    public static void main(String[] args) {
        System.out.println("My Program");
    }
}

Note that the Class definition and the file name should be the same (In this case MyProgram).

Compiling codes to generate bytecode

In the command prompt, type

javac MyProgram.java

The MyProgram.class file will be generated.

Running the bytecode in Java platform

Now go to Command Prompt and run the Class file by typing
java MyProgram

See the output in your screen.