Java Programming Notes

Introduction to Java Programming
  • Java programming focuses on developing applications using the Java language.
Objectives
  • Become Familiar with Java Language: Understand its syntax, semantics, and structure.
  • Java Language Editions: Explore various editions of Java available.
  • Importance of Java: Recognize the significance of Java in modern software development.
  • Java as an Independent Platform: Learn about Java's portability and platform independence.
  • Java Platform Components: Understand the components which include:
    • Java Compiler
    • Java Development Kit (JDK)
    • Java Runtime Environment (JRE)
    • Java Virtual Machine (JVM)
    • Java Just-In-Time Compiler (JIT)
  • Processing of Java Programs: Explore how a Java program is executed step-by-step.
Procedural Programming
  • Definition: A programming paradigm composed of procedures that perform specific tasks.
  • Data Handling: Procedures operate on separate data items, which are typically passed between procedures.
  • Focus: To create procedures that effectively manipulate the program's data.
Object-Oriented Programming (OOP)
  • Definition: A programming paradigm centered around creating objects.
  • Objects: Entities that encapsulate data (data attributes) and methods (procedures).
    • Data Attributes: Properties of the object.
    • Methods: Functions that operate on the data attributes.
What is Java?
  • Object-Oriented Language: Java is designed to be an object-oriented programming language.
  • Origin: Developed by Sun Microsystems in 1991 under the Green Team project.
  • General Purpose: Created for a variety of applications including desktop, web, mobile, and games.
  • WORA: Known as "Write Once, Run Anywhere" due to portability across platforms.
Java Program Structure
  • Example Program: A simple Java program to display "Welcome to JAVA!"
public class Welcome {
    public static void main(String[] args) {
        System.out.print("Welcome to JAVA!");
    }
}
  • Flow of Execution:
    • Development: Programmers create source code.
    • Compilation: Source code is compiled into bytecode using a Java compiler javac.
    • Execution: Bytecode runs on the JVM to 'interpret' and display the result.
Java Development Editions
  • Java Standard Edition (J2SE): For developing standalone apps.
  • Java Enterprise Edition (J2EE): For server-side applications.
  • Java Micro Edition (J2ME): For mobile device applications.
  • Current Course: Focuses primarily on J2SE.
Components of Java Platform
  • JDK (Java Development Kit): Development tools and environment for creating Java applications.
  • JRE (Java Runtime Environment): Environment to run Java applications.
  • JVM (Java Virtual Machine): Executes Java bytecode on any platform.
    • Relationship: JDK = JRE + Development Tools; JRE = JVM + Library Classes.
Java Development Kit (JDK)
  • Purpose: Essential for developing Java applications.
    • Contents:
    • Compiler: Converts source code into bytecode.
    • Core Class Library: Fundamental Java classes.
    • Debugger (jdb), Bytecode Interpreter (JVM), Documentation Generator (javadoc), Jar Utility.
  • Significance: JDK is indispensable for building any Java program; must select version and edition based on needs.
Java Runtime Environment (JRE)
  • Function: Runs Java applications, requiring the presence of JVM.
  • Resources: Contains inbuilt packages and class libraries necessary for executing Java applications.
Java Virtual Machine (JVM)
  • Platform Independence: Can run on any operating system due to its nature of handling bytecode.
  • Memory Management: JVM is responsible for effective memory management and execution of Java code.
  • JIT (Just In Time Compiler): Enhances performance by compiling bytecode to machine code at runtime.
Java as an Independent Computing Platform (Portability)
  • Definition of Portability: Ability to run on different types of computers without modification.
  • Execution Flow: Compiled Java programs create bytecode that can run on any JVM, making it highly portable across various platforms (Windows, UNIX, MAC, Mobile).
Java IDEs (Integrated Development Environments)
  • Purpose: Facilitates software development with tools for coding, compiling, debugging, and testing.
  • Examples of IDEs:
    • NetBeans
    • Eclipse
    • BlueJ
    • IntelliJ IDEA
  • Course Tool: This course will focus on using NetBeans IDE.
References
  • Liang, D. (2019). Introduction to Java Programming, Comprehensive Version, Student Value Edition, 12th Edition, Pearson.
  • Educational resources: lectures and videos from designated sources.
  • Installation manuals for JDK and NetBeans IDE.