To Compiling and Running a Java Program we need to confirm that jdk installed on your computer or not. If not installed then install JDK.(Download from here).

Step 1: Write Program

Open any text editor like Notepad or Notepad++ and Write your program you want to run. For example

Save below code as Example.java in bin directory of jdk. Please keep attention that Java programs are case sensitive.

Always save any Java program with name of Class.

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

Step 2: Compiling Java Program

Compiling Java program is a process in which any java file converted to .class file or bytecode.
Open Command Prompt and go to the location where you save Example.java
And type javac followed by java file name.
>javac Example.java

Step 3: Running compiled Java Program

After successful compilation of java program we use java command to run this program.
Type
>java Example

After pressing Enter it gives output on console as

output>Example Program !

Compiling and Running a Java Program

Compiling and Running a Java Program