Getting Started
Basic Program Structure
Section titled “Basic Program Structure”- 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
$ javac com/example/Main.java$ java com/example/MainHello 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
javaccommand which is then in-turm run in JVM - Read more Details about JDK, JRE & JVM
- How java compilation works ?