ITEC 30 2

Introductory Overview
  • Instructors: Juel D. Coper, Rumer M. Bayot

Presentation Outline
  • 1. Introduction

  • 2. What is Java?

  • 3. The Java Language Specification, API, JDK, and IDE

  • 4. A Simple Java Program

  • 5. Creating, Compiling and Executing A Java Program

Introduction
  • Computer Programs - Known as software.

    • Defined as instructions to the computer, telling it what to do.

    • Consists of a series of instructions directing the computer to perform specific operations.

Programming
  • Definition of Programming

    • The process of creating a program that is executable by a computer, designed to perform required tasks.

  • Programming Language

    • A formal language specifying a set of instructions to produce various kinds of output.

  • Characteristics of Programming Language

    • Contains a specialized vocabulary allowing communication of instructions to a computer in an understandable way.

Types of Programming Languages
1. Machine Language
  • Definition: A computer's native language, which varies across different types of computers.

  • Description: A set of built-in primitive instructions specific to the hardware.

2. Assembly Language
  • Definition: Uses short descriptive words known as mnemonics to represent machine-language instructions.

  • Purpose: Developed to simplify programming relative to write in machine code.

3. High-Level Language
  • Platform Independence: Programs can be executed on various machines without modification.

  • Ease of Use: English-like syntax makes it easier to learn and implement.

Examples of High-Level Programming Languages
  • COBOL (COmmon Business Oriented Language)

  • FORTRAN (FORmula TRANslation)

  • BASIC (Beginner's All-purpose Symbolic Instruction Code)

  • Pascal

  • Ada (named for Ada Lovelace)

  • C

  • Visual Basic

  • Delphi

  • C++ (object-oriented, based on C)

  • C# (Java-like, developed by Microsoft)

  • Python

  • JAVA

What is JAVA?
  • Java Characteristics:

    • High-Level Programming Language

    • Platform Independent

    • Object-Oriented

  • Definition:

    • "Java is a powerful and versatile programming language for developing software running on mobile devices, desktop computers, and servers."

Advantages of Choosing JAVA
  • Simplicity: - Easier design, writing, and compilation compared to other languages.

  • Object-Oriented: - Supports modular programming and reusable code.

  • Platform Independence: - Flexible nature allowing cross-platform compatibility.

  • Distributed Environment: - Works effectively across distributed networks.

  • Security: - Java provides advanced security features.

  • Robustness: - Reliability and stability of applications.

  • Multithreaded Support: - Allows multiple threads of execution, enhancing efficiency.

About JAVA
  • Origin:

    • Developed by a team led by James Gosling at Sun Microsystems, originally called Oak.

    • Created in 1991 for embedded chips in consumer electronics.

    • Renamed Java in 1995 for web application development.

  • Key Feature:

    • Write Once, Run Anywhere (WORA): Code written in Java does not require recompilation to run on different platforms.

The Java Language Specification, API, JDK, and IDE
  • Java Language Specification: - A technical definition that encompasses syntax and semantics of Java.

  • Application Program Interface (API): - Contains predefined classes and interfaces for developing Java programs.

  • Java Development Kit (JDK): - A software development environment for Java applications and applets, includes:

    • Java Compiler (javac)

    • Java Archiving Tool (jar)

    • Java Debugger (jdb)

    • Java Runtime Environment (JRE) (for running Java programs)

Java Editions
  • Java Standard Edition (Java SE):

    • Used to develop client-side applications that can run standalone or as applets from a web browser.

  • Java Enterprise Edition (Java EE):

    • For developing server-side applications including Java servlets, JavaServer Pages (JSP), and JavaServer Faces (JSF).

  • Java Micro Edition (Java ME):

    • Designed for mobile applications, such as those on cell phones.

  • JavaFX:

    • A platform for creating rich internet applications using a lightweight user-interface API.

Java Versions
  • Major Java releases with corresponding dates:- JDK Alpha and Beta: 1995 - Basic features for application support.

    • JDK 1.0: January 23, 1996 - Introduction of Access Specifies.

    • J2SE 1.1: February 19, 1997 - Focus on Database connectivity & RMI.

    • J2SE 1.2: December 8, 1998 - Introduction of JIT Compilation and Collection Framework.

    • J2SE 1.3: May 8, 2000 - Introduction of JAR indexing, JAR sound.

    • J2SE 1.4: February 6, 2002 - Introduced XML Processing, Printing, JDBC.

    • J2SE 5.0: September 30, 2004 - Introduction of Boxing/Unboxing, Generics.

    • Java SE 6: December 11, 2006 - Introduction of Pluggable Annotations, Java GSS.

    • Java SE 7: July 28, 2011 - Introduction of Multiple Exception Handling and Automatic null Handling.

    • Java SE 8: March 18, 2014 - Introduction of Lambda Expressions, Type Annotations.

    • Java SE 9: September 2017.

    • Java SE 10: March 2018.

    • Java SE 11 (LTS): September 2018.

    • Java SE 12 to SE 21: Released in ensuing years through March 2023.

Integrated Development Environment (IDE)
  • Definition: A software that provides a comprehensive environment for developing Java programs, including editing, compiling, building, debugging, and help features all integrated into a GUI.

Examples of IDEs
  • Netbeans

  • JCreator

  • JEdit

  • Eclipse

  • JBuilder

  • Blue J

  • JGRASP

  • Sun Java Studio

A Simple Java Program
Example Java Code
public class Welcome {
    public static void main(String[] args) {
        // Display message "Welcome to Java!" to the console
        System.out.println("Welcome to Java!");
    }
}
Structure of the Program
  • Class Declaration: public class Welcome

  • Main Method Declaration: public static void main(String[] args)

  • Commentary: Indicates the purpose

  • Print Statement: System.out.println("Welcome to Java!");

Creating, Compiling and Executing a Java Program
  1. Create/Modify Source Code: - Source code developed by the programmer is saved as Welcome.java.

public class Welcome {
      public static void main(String[] args) {
          System.out.println("Welcome to Java!");
      }
  }
  1. Compile Source Code:

    • Compile using Java Compiler: javac Welcome.java.

    • If compilation errors occur, they will be displayed.

    • Compiled code is stored on disk as Welcome.class.

  2. Run Bytecode:

    • Execute using JVM: java Welcome.

    • If runtime errors or incorrect results occur, they will be reported.

    • Confirm output on console: Welcome to Java!.

Key Components
  • Java Virtual Machine (JVM): A virtual machine that runs Java bytecode, implemented in software.

  • Bytecode: Architecture-neutral similar to machine instructions, executable on any platform with JVM.

  • Java Runtime Environment: Provides libraries, tools, and the JVM for running Java applications.