How to create Java program from scratch

To start creating Java program from scratch using text editor, first open any text editor like notepad, write your code for example:

public class Hello {    
    public static void main(String[] args) {
 System.out.println("Hello world!"); 
    }    
}

The first line of code declare a class Hello, inside the main method is the output command to display or print the string “Hello world!” to computer screen. After the code is type in the text editor, save it with a filename “Hello.java” because in Java, the name of a Java code file should be the same with the name of the class. 

After creating and saving your Java program, compile the program by using the Java Compiler. You can do this by typing Javac Hello.java at the command prompt. The output of this process is a file of Java bytecodes with the file extension .class. After you compile the java code, it will create a file Hello.class.

The Hello.class file is then interpreted by the Java interpreter that converts the Java byte codes into the machine language of the particular computer you are using. You can run your Hello world java program by typing Java Hello into the command prompt.

To summarize on how to create Java program, you need to write Java code in a text editor, and save it with .java extension.  Then, compile the Java code using the Java compiler, it will create a Java byte code or the class file. And finally run the program using Java interpreter. Aside from text editor you can also use eclipse to create and run Java programs.