Creating first program in java

  • Every java program start with class
  • Class name should be (not must be) start with capital letter
  • Class name should be same as file name (Because byte code always created with class name).
  • Class name start with alphabet or underscore or dollar
  • Syntax
class FirstClass{

To compile the source code we simply type on cmd or Terminal :

>> javac <FileName>.java

It will compile the code, convert source code to byte code

>> java <ByteCodeFileName/ClassName>

It will execute the code, convert byte code to native code

javac comes from JDK

java command comes from the JRE

Defining Main Method

public static void main(String args[]) {

Like every house has main gate to enter , same here every java program has main method , so it is an entry point of every java program.

  • main() is Entry point of java program
  • If main is not defined then when we convert source code into byte code it will work perfectly, but during execution it will raise error, because there is no entry point.

Writing First Java Program Video ⬇️

class SecondClass{
      public static void main(String args[]){
        System.out.println("Hello Java");
Writing First Java Program

Understanding main method signature video ⬇

That's all Folks , See you in next Tutorial 😎