ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)

Set your Publisher ID in src/config/ads.ts to display live ads.

Java Tutorial• 6 min read

Java Introduction & First Program

Write Once, Run Anywhere (WORA), JVM architecture, and Main method

Java is an enterprise-grade, statically-typed, class-based object-oriented language developed by Sun Microsystems (now Oracle) in 1995.

Understanding the JVM and Class Structure

WORA (Write Once, Run Anywhere): Java compiles code into portable bytecode (.class files), which executes on any system equipped with a Java Virtual Machine (JVM).

JDK vs JRE vs JVM: JDK (Java Development Kit) contains compiler (javac) and tools; JRE provides libraries to run code; JVM executes bytecode.

Every standalone Java program must declare a public class matching the file name (e.g. Main.java) with the entrypoint public static void main(String[] args).

First Java Program (Main.java)
public class Main {
    public static void main(String[] args) {
        System.out.println("Welcome to Codexia Java Mastery!");
        
        String studentName = "Sameera";
        int xp = 150;
        System.out.println("Student: " + studentName + " | XP: " + xp);
    }
}
System.out.println() prints messages followed by a line break to the console.
ADVERTISEMENT
Google AdSense Slot (inContentBanner)

Set your Publisher ID in src/config/ads.ts to display live ads.

Test Yourself With Exercise

+15 XP

Which method serves as the universal runtime entry point for standalone Java applications?