Skip to content

Getting Started

  • Package Structure
~ $ tree .
.
└── com
└── example
└── Main.java
  • Base Java Program
package com.example;
public class Main {
public static void main(String... args) {
String greetingMessage = "Hello World";
greet(greetingMessage);
}
private static void greet(String message) {
System.out.println(message);
}
}
  • Compiling & Running the program
Terminal window
$ javac com/example/Main.java
$ java com/example/Main
Hello World
$
  • Entry point to the java application during execution is the main function signature public static void main(String[] args) {...} . JVM looks for this method signature as default.
  • JVM - Executes the bytecode generated by the compiler, Makes java code platform-independent
  • Bytecode - Compiled output of the javac command which is then in-turm run in JVM
  • Read more Details about JDK, JRE & JVM
  • How java compilation works ?