Lesson 1 of 50 – Introduction to Java
2%

Introduction to Java

Java is a popular, high-level programming language known for its object-oriented programming features, portability, and reliability. It is widely used for software development, web applications, enterprise applications, backend systems, and many other areas.

Note: Java follows the principle "Write Once, Run Anywhere" because compiled Java bytecode can run on different systems that have a compatible Java Virtual Machine (JVM).
What is Java?

Java is a high-level, general-purpose programming language developed to create different types of computer applications.

Java programs are commonly organized using classes and objects. Java also supports other programming techniques where appropriate.

  • Java is a high-level programming language.
  • Java supports object-oriented programming.
  • Java is platform-independent through the JVM.
  • Java supports automatic memory management.
  • Java provides exception-handling features.
  • Java is widely used in enterprise applications.
  • Java has a large standard library and ecosystem.
History of Java

Java was developed by James Gosling and his team at Sun Microsystems. Its development began in 1991, and Java was publicly released in 1995.

Feature Information
Creator James Gosling and his team
Development Started 1991
First Released 1995
Original Name Oak
Original Company Sun Microsystems
Current Development Oracle and the OpenJDK community
Type High-level programming language
Features of Java
  • Simple: Java has a structured and familiar syntax.
  • Object-oriented: Java supports classes and objects.
  • Platform-independent: Java bytecode runs on compatible JVMs.
  • Secure: Java provides several runtime security features.
  • Robust: Java supports exception handling and memory management.
  • Multithreaded: Java supports concurrent task execution.
  • Portable: Java bytecode is designed for different platforms.
  • Automatic memory management: Java uses garbage collection.
  • Rich libraries: Java provides many built-in classes and APIs.
  • Network support: Java includes APIs for network programming.
Why Learn Java?

Java is an important programming language for students who want to learn software development, object-oriented programming, and application development.

  • Useful for learning object-oriented programming.
  • Used in large business applications.
  • Used to build backend services and APIs.
  • Supports database connectivity through JDBC.
  • Offers many libraries and development tools.
  • Useful for learning data structures and algorithms.
  • Used in Android development, although Android also uses Kotlin.
  • Provides opportunities in software development careers.
Applications of Java

Java is used in many areas of software development and modern technology.

  • Desktop applications
  • Web applications
  • Enterprise software
  • Banking and financial systems
  • Backend development
  • REST APIs and web services
  • Android applications
  • Cloud-based applications
  • Database applications
  • Scientific and business software
  • Distributed systems
Java and Operating Systems

Java is designed to support different operating systems. A Java program can run on a system that has a compatible Java runtime environment.

Operating System Java Support
Windows Yes
Linux Yes
macOS Yes

Example: A compiled Java program can run on Windows or Linux if the required Java runtime and compatible dependencies are available.

First Java Program

Let's write our first Java program. The System.out.println() statement is used to display text on the screen.

Example:
public class Main {
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}
Output:
Hello World!

The System.out.println() statement displays the text inside the parentheses and moves the cursor to the next line.

Save this program as Main.java. The filename must match the public class name.

Java Syntax

Java syntax refers to the rules used to write valid Java programs. Java statements commonly end with semicolons, and curly braces define code blocks.

Example:
public class Main {
    public static void main(String[] args) {
        int number = 10;

        if (number > 5) {
            System.out.println("Number is greater than 5");
        }
    }
}
Output:
Number is greater than 5

The curly braces define the class, method, and conditional block. Java is case-sensitive, so Main and main are different identifiers.

Java Compiler and JVM

Java source code is compiled into bytecode. The Java Virtual Machine (JVM) executes this bytecode.

How Java works:

Java Source Code (.java)
          |
          v
    Java Compiler (javac)
          |
          v
    Bytecode (.class)
          |
          v
    Java Virtual Machine (JVM)
          |
          v
      Program Output

Important components:

  • JDK: Java Development Kit, which provides tools for developing Java programs.
  • JVM: Java Virtual Machine, which executes Java bytecode.
  • Compiler: The javac tool compiles Java source code into bytecode.
Java Program File

Java source code is normally saved using the .java file extension. After compilation, the compiler generally produces a .class file containing bytecode.

Example:
Main.java

Compile the program:

javac Main.java

Run the program:

java Main

These commands work when a suitable JDK is installed and its tools are available in the command line.

Advantages of Java
  • Supports object-oriented programming.
  • Runs on multiple supported platforms.
  • Provides automatic memory management.
  • Includes exception-handling mechanisms.
  • Offers extensive standard libraries.
  • Supports multithreaded programming.
  • Has a large developer community.
  • Supports database connectivity.
  • Suitable for enterprise applications.
  • Provides a mature ecosystem of development tools.
Java vs Other Programming Languages
Feature Java Python C
Syntax Structured and explicit Concise and readable Structured and procedural
Programming Style Supports OOP and other styles Supports multiple paradigms Primarily procedural
Execution Bytecode on a JVM Typically uses an interpreter/runtime Typically compiled to native code
Memory Management Garbage collection Automatic memory management Often managed by the programmer
Common Uses Enterprise and backend applications AI, data, automation, and web Systems and embedded programming
Key Points
  • Java is a high-level programming language.
  • Java was developed by James Gosling and his team.
  • Java was first publicly released in 1995.
  • Java supports object-oriented programming.
  • Java bytecode can run on compatible JVMs.
  • The JDK includes tools for developing Java programs.
  • The JVM executes Java bytecode.
  • Java source files normally use the .java extension.
  • The javac command compiles Java source code.
  • The System.out.println() statement displays output.
  • Java is used in enterprise software, backend systems, and many other applications.


🧠 Quick Quiz

1. Who is commonly known as the father of Java?





2. What does JVM stand for?





3. Which file extension is normally used for Java source code?