0% found this document useful (0 votes)
29 views18 pages

OOPs 86

This document is an assignment on Java Development and Versions, covering the Java Development Kit (JDK), its components, and the evolution of Java through its various versions. It details the purpose of JDK, the differences between Java SE and Java EE, and provides a breakdown of significant Java versions from 1.0 to 21, highlighting key features and improvements. The document also includes a brief overview of Java syntax and a simple Java program example.

Uploaded by

itsareeba234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views18 pages

OOPs 86

This document is an assignment on Java Development and Versions, covering the Java Development Kit (JDK), its components, and the evolution of Java through its various versions. It details the purpose of JDK, the differences between Java SE and Java EE, and provides a breakdown of significant Java versions from 1.0 to 21, highlighting key features and improvements. The document also includes a brief overview of Java syntax and a simple Java program example.

Uploaded by

itsareeba234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Submitted By: Abdur Rehman

Submitted To: Sir Ahmed Zeeshan


Roll No: BSCS012415086
Subject: OOPs Theory
Assignment 1

1
Table of Contents
1. Java Development Kit (JDK)............................................................................................... 3
2. Java Versions ................................................................................................................... 4
3. Java Standard Editions (Java SE & Java EE)........................................................................ 7
4. Java Syntax ..................................................................................................................... 10
5. Java History & Company ................................................................................................. 12
6. JVM, JRE, and JDK ........................................................................................................... 15
7. Strength & Limitations of JAVA........................................................................................ 17

2
Assignment #1: Java Development & Versions
1. Java Development Kit (JDK)
The Java Development Kit (JDK) is a software development environment provided by
Oracle (and other vendors) for building applications using the Java programming
language. It is a core component for developing Java programs and includes
everything needed to compile, debug, and run Java applications.

Components of JDK:
The JDK consists of the following main components:
1. Java Compiler (javac)
Translates Java source code (.java files) into bytecode (.class files) that the Java Virtual
Machine (JVM) can execute.
2. Java Runtime Environment (JRE)
Includes the JVM, core libraries, and other components necessary to run Java
applications.
3. Java Virtual Machine (JVM)
Executes Java bytecode and provides platform independence.
4. Java API Libraries
Pre-built classes and interfaces for performing common programming tasks (e.g., data
structures, file handling, networking, etc.).
5. Development Tools
Includes tools like:
▪ javap (class file disassembler),
▪ javadoc (for generating documentation),
▪ jar (for packaging Java files into a .jar archive),
▪ jshell (interactive Java shell for testing code snippets).
6. Debugger (jdb)
Helps in debugging Java applications.

Purpose of JDK in Java Development:


• Code Compilation: Converts human-readable source code into bytecode using
the Java compiler.

3
• Application Testing and Debugging: Provides tools to test and debug Java
programs effectively.
• Running Java Programs: Through the JRE, it enables running and testing Java
applications.
• Documentation Generation: Allows automatic generation of API
documentation using javadoc.
• Packaging and Deployment: Facilitates packaging of applications using jar and
other tools.
…………………………………
2. Java Versions
ava, since its launch in 1996, has gone through multiple significant updates. Each
version added new features, enhanced performance, and improved developer
productivity. Below is a breakdown of the major Java versions and their most important
additions.

• Java 1.0 (1996) – The Beginning


Java 1.0 was the first public release by Sun Microsystems. It introduced the foundation
of the Java language including object-oriented programming concepts like classes,
inheritance, and polymorphism. It provided the ability to create platform-independent
applications using the Java Virtual Machine (JVM). Core features included the Abstract
Window Toolkit (AWT) for GUI programming and the capability to create small Java
programs called applets that could run in web browsers.

• Java 1.1 (1997) – Important Enhancements


Java 1.1 brought several key improvements to the language. It introduced inner classes,
which allowed nesting of one class within another. The Reflection API was added,
enabling Java programs to inspect and manipulate objects at runtime. JavaBeans, a
component architecture for building reusable software components, was also
introduced. JDBC (Java Database Connectivity) made its debut, allowing Java
applications to connect and interact with databases.

• Java 2 (J2SE) 1.2 (1998) – The Collections Era


This version was a major leap forward and marked the beginning of the “Java 2”
platform. The most significant addition was the Collections Framework, which included
interfaces and classes for data structures like List, Set, Map, etc. Swing was introduced
as a new GUI toolkit that replaced AWT and provided a more powerful, platform-
independent user interface. It also introduced Just-In-Time (JIT) compilation to improve
performance.

• Java 1.3 (2000) – Stability and Performance

4
Java 1.3 focused on performance and scalability. It included the HotSpot JVM for better
runtime performance. New APIs for audio (Java Sound) were added, and Remote
Method Invocation (RMI) was enhanced to support distributed applications better.

• Java 1.4 (2002) – Modern Programming Support


Java 1.4 introduced several important features. The assert keyword was added to
support debugging through assertions. Regular expression support was added to the
standard library, making string pattern matching easier. The New I/O (NIO) package
provided faster and more scalable I/O operations. Exception chaining was introduced to
make error handling more comprehensive. A logging API was also added for application
logging and monitoring.

• Java 5 (2004) – A Revolutionary Update


Java 5, also referred to as JDK 1.5, was one of the biggest updates to the language. It
introduced generics, allowing developers to write type-safe code with collections and
other classes. Annotations were added, enabling metadata to be added to code and
paving the way for modern frameworks like Spring and Hibernate. The enhanced for-
loop (for-each loop) simplified iterating over collections. Autoboxing and unboxing
allowed automatic conversion between primitive types and their wrapper classes.
Enumerations (enums) provided a clean way to define constant values, and varargs
(variable arguments) enabled methods to accept an arbitrary number of parameters.
These features made Java more expressive and developer-friendly.

• Java 6 (2006) – Performance and Web Services


Java 6 focused mainly on performance improvements, API updates, and better support
for web services. It introduced scripting language support through JSR 223 (especially
JavaScript with Rhino). Java Compiler API was introduced, allowing Java code to be
compiled from within programs. Enhancements in GUI components were also made.
Though not a feature-rich update for syntax, it made Java more stable and enterprise-
ready.

• Java 7 (2011) – Project Coin and NIO.2


Java 7 introduced several small but significant language enhancements under a project
called Project Coin. These included:
➢ Strings in switch statements,
➢ Binary literals,
➢ Underscores in numeric literals for readability,
➢ Diamond operator (<>) for simplifying generic instantiation. Another major
improvement was try-with-resources, which allowed automatic management
and closing of resources like files and sockets. It also introduced the NIO.2
package for advanced file I/O operations, including symbolic links and

5
asynchronous file channels. Java 7 also enhanced exception handling with
multi-catch and more precise rethrowing.

• Java 8 (2014) – A Paradigm Shift


Java 8 was a groundbreaking release that transformed Java into a modern programming
language. The most important feature was the introduction of Lambda expressions,
enabling functional-style programming. Along with lambdas came the Streams API,
which allowed developers to process collections of data in a declarative and parallel-
friendly manner. Functional interfaces like Predicate, Function, and Consumer were
added. Default and static methods in interfaces allowed developers to add methods
to interfaces without breaking existing code. Java 8 also introduced the new java.time
package for handling dates and times more accurately and effectively. Other features
included Optional to handle null values more gracefully and Nashorn, a new JavaScript
engine.

• Java 9 (2017) – Modularity with Project Jigsaw


Java 9 introduced Project Jigsaw, which brought modularity to the Java platform. It
allowed developers to break large applications into smaller, manageable modules. The
JDK itself was modularized, improving scalability and security. JShell, an interactive
Read-Eval-Print-Loop (REPL), was introduced to help developers test small code
snippets quickly. The Streams API was enhanced with new methods like takeWhile,
dropWhile, and iterate. Javadoc was improved with a built-in search feature.

• Java 10 (2018) – Local Variable Type Inference


Java 10’s main highlight was type inference using the var keyword. Developers could
now declare local variables without explicitly writing the type if it was obvious from the
context. This made code more concise and readable. Java 10 also introduced
application class-data sharing (AppCDS) for faster startup times.

• Java 11 (2018) – Long-Term Support (LTS)


Java 11 is an important Long-Term Support (LTS) release. It introduced a new HTTP
Client API that replaced the old HttpURLConnection. This modern client supports
synchronous and asynchronous programming. Several new string methods were
added, such as isBlank(), lines(), and repeat(). The var keyword could now be used in
lambda parameters, and the ZGC (Z Garbage Collector) was introduced for low-latency
performance. JavaFX was removed from the JDK and made available as a separate
module.

• Java 12 to 15 (2019–2020) – Preview Features and Enhancements


These versions introduced a series of preview features and incubator APIs:
➢ Switch expressions (which allowed switch to return values),
➢ Text blocks (multi-line string literals),

6
➢ Pattern matching (simplifying instanceof checks),
➢ Records (a concise way to declare data-carrying classes),
➢ Sealed classes (for restricted inheritance).

• Java 16 to 17 (2021) – Modern Java


Java 16 finalized the record feature and introduced sealed classes to control which
classes can extend a superclass. Java 17, also an LTS release, brought in further
refinements to pattern matching and sealed classes, along with enhancements in the
JDK's internal architecture and performance.

• Java 18 to 20 (2022–2023) – Incubator and Preview Features


These versions continued to develop features like virtual threads, structured
concurrency, and enhancements to pattern matching and record patterns. They were
primarily used for testing features before formal inclusion in LTS versions.

• Java 21 (2023) – Powerful Modern Java (LTS)


Java 21 is a Long-Term Support version and one of the most advanced Java releases to
date. It introduces virtual threads from Project Loom, making concurrent programming
easier and more scalable without the heavy cost of traditional threads. It adds support
for record patterns, pattern matching for switch, and string templates (in preview),
simplifying dynamic string generation. It also includes sequenced collections, offering a
consistent order to sets and maps.
…………………………………

Java SE (Standard Edition)


Definition:
Java SE (Java Platform, Standard Edition) is the core foundation of the Java
programming language. It provides all the basic libraries and tools needed to develop
general-purpose applications using Java. This platform includes the Java Development
Kit (JDK), Java Runtime Environment (JRE), and a wide range of core APIs that allow
developers to write code for both desktop and embedded systems.
Uses and Applications:
Java SE is mainly used to develop standalone applications that do not require a web
browser or a server. It is ideal for:
• Desktop applications like calculators, media players, or personal finance
software.
• Command-line utilities and scripts, such as file handling programs.
• Client-side applications that run on personal computers.

7
• Learning and teaching object-oriented programming (OOP) concepts such as
classes, objects, inheritance, and polymorphism.
• Developing core algorithms, data structures, and logical programs.
• Basic network programming (sockets, URLs).
• Database applications using JDBC (Java Database Connectivity).
• Graphical User Interfaces (GUI) using libraries such as AWT (Abstract Window
Toolkit) and Swing.
Java SE is also the base platform upon which other editions like Java EE and Java ME
(Micro Edition) are built. Without Java SE, these higher editions cannot function.

Java EE (Enterprise Edition)


Definition:
Java EE (Java Platform, Enterprise Edition), now known as Jakarta EE, is a powerful
platform built on top of Java SE, designed specifically for the development of large-
scale, distributed, and server-based applications. It provides a rich set of APIs and
tools for building multi-tier enterprise-level applications that require security,
scalability, and reliability.
Uses and Applications:
Java EE is widely used in enterprise and corporate environments for building:
• Web applications using Servlets and JSP (JavaServer Pages).
• Enterprise applications with complex business logic using EJB (Enterprise
JavaBeans).
• Multi-tier distributed systems involving a client layer, business logic layer, and
database layer.
• Web services using JAX-RS (for RESTful services) and JAX-WS (for SOAP-based
services).
• Database-driven applications using JPA (Java Persistence API) for ORM (Object
Relational Mapping).
• Email-based systems using JavaMail API.
• Message-driven applications using JMS (Java Messaging Service) for
asynchronous communication.
• Secure applications using Java EE’s built-in support for authentication,
authorization, and encrypted communication.
• Transaction management systems that ensure consistency and rollback
mechanisms in enterprise workflows.

8
Java EE applications are typically deployed on application servers such as:
• GlassFish
• WildFly (formerly JBoss)
• Apache TomEE
• IBM WebSphere
• Oracle WebLogic
These servers manage the application lifecycle, security, resource management, and
scalability of enterprise Java applications.

Comparison: Java SE vs Java EE


1. Purpose and Scope:
• Java SE is designed for general-purpose programming. It includes the basic
tools required for Java development and is focused on building client-side or
standalone applications.
• Java EE, on the other hand, is tailored for enterprise-level, web-based, and
server-side applications. It provides additional libraries and features to support
business needs.
2. Components and APIs:
• Java SE includes core APIs such as:
➢ java.lang (core classes like String, Math, etc.)
➢ java.util (collections framework)
➢ java.io (input/output)
➢ java.net (networking)
➢ java.sql (JDBC for database interaction)
➢ java.time (date and time API)
• Java EE includes all of Java SE and adds:
➢ javax.servlet and javax.jsp for web development
➢ javax.ejb for enterprise beans
➢ javax.persistence for database access (JPA)
➢ javax.jms for message services
➢ javax.ws.rs and javax.ws.soap for web services
➢ javax.mail for email handling
3. Application Type:
• Java SE is used for creating desktop applications, tools, and command-line
utilities.

9
• Java EE is used for building multi-tier web applications, enterprise systems,
and large-scale distributed applications.
4. Architecture:
• Java SE applications are typically single-tier, running on a single machine or
user environment.
• Java EE applications are multi-tiered, usually involving:
➢ A client tier (e.g., a web browser or mobile app)
➢ A web tier (e.g., JSP/Servlets)
➢ A business tier (e.g., EJBs, services)
➢ A data tier (e.g., database backend)
5. Development Focus:
• Developers using Java SE focus on the logic and structure of applications,
managing everything manually.
• In Java EE, developers focus on business logic, while the container (application
server) handles security, transactions, resource management, and
scalability.
6. Deployment Environment:
• Java SE applications are deployed on local machines with a JRE.
• Java EE applications are deployed on application servers that manage the
environment and runtime services.
…………………………………

4. Java Syntax
Java syntax refers to the set of rules that define how a Java program should be written
and interpreted by the Java compiler. Java is a strictly-typed, object-oriented, and case-
sensitive programming language, and its syntax is similar to C and C++.
A typical Java program is made up of:
1. Class Declaration
2. Main Method
3. Statements and Expressions
4. Comments
A Simple Java Program: “Hello, World!”
public class HelloWorld {

10
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

Explanation:
• public class HelloWorld: This declares a class named HelloWorld. Every Java
program must have at least one class.
• public static void main(String[] args): This is the main method where
program execution begins. The JVM (Java Virtual Machine) looks for this method
to start the application.
• System.out.println("Hello, World!");: This line prints the message to
the console. It's a standard output statement.
• {}: Curly braces define the body of classes and methods.

Java Syntax Rules and Structure


1. Class Declaration:
Every Java program must contain at least one class definition. The class name should
match the file name (e.g., HelloWorld.java).
public class HelloWorld {
// code
}
2. Main Method:
This is the entry point for execution in a Java application. It must be written exactly like
this:
public static void main(String[] args) {
// code
}
• public: Accessible by the JVM.
• static: It can be run without creating an object of the class.
• void: Returns nothing.
• main: The name recognized by JVM as the starting point.
• String[] args: Accepts command-line arguments.

11
3. Statements:
Statements in Java end with a semicolon (;). For example:
java
System.out.println("Hello");
4. Braces and Indentation:
Code blocks are enclosed within curly braces {}. Proper indentation improves
readability but is not syntactically required.
5. Case Sensitivity:
Java is case-sensitive. For example:
• System and system are different identifiers.
• main must be lowercase; Main will not be recognized.
6. Comments:
Used to explain code.
// This is a single-line comment
/* This is a
multi-line comment */
7. Identifiers and Naming:
• Class names: Start with uppercase (e.g., HelloWorld)
• Variable/method names: Start with lowercase (e.g., myVariable, printData)
• Must not use reserved keywords (like int, class, public) as names.
…………………………………

5. Brief History of Java


Java is a high-level, object-oriented programming language that was originally
developed in the early 1990s. It was designed to be platform-independent, meaning
programs written in Java could run on any device that had the Java Virtual Machine
(JVM).
1991 – The Birth of Java (Initially Called Oak)
• Java was initiated as a project called "Green Project" by James Gosling, Mike
Sheridan, and Patrick Naughton at Sun Microsystems.
• The project aimed to create a language for programming home appliances, such
as TVs, VCRs, and toasters.

12
• The language they created was originally called Oak, named after an oak tree
outside Gosling's office.
• However, Oak was later renamed to Java in 1995 due to trademark issues (the
name Oak was already in use).
1995 – Java’s Public Launch
• Java was officially launched by Sun Microsystems in 1995.
• It was introduced with the slogan: “Write Once, Run Anywhere” (WORA).
• The idea was that Java programs could run on any device or operating system
that had the JVM installed, without modification.
• Java quickly gained popularity due to its portability, simplicity, and security
features.
1996 – First Official Java Version (JDK 1.0)
• Sun released the first version of Java Development Kit (JDK 1.0) in 1996.
• This included core classes, JVM, and development tools like javac and java.
• Java was mainly used for web applets embedded in browsers during the early
internet era.
Late 1990s – Java’s Rise
• Java became widely adopted for building web applications, enterprise
software, and mobile apps.
• Java 2 (J2SE, J2EE, and J2ME) was introduced, separating the platform into
different editions:
➢ J2SE (Standard Edition) for desktop applications
➢ J2EE (Enterprise Edition) for large-scale business applications
➢ J2ME (Micro Edition) for mobile and embedded devices
2006 – Java Becomes Open Source
• In 2006, Sun Microsystems made Java open-source under the GNU General
Public License (GPL).
• This move led to the creation of OpenJDK, the official open-source version of
Java.
2010 – Oracle Acquires Sun Microsystems
• In January 2010, Oracle Corporation acquired Sun Microsystems.
• This gave Oracle control over Java and its future development.

13
Role of Sun Microsystems in Java Development
Sun Microsystems played a foundational role in the creation and early success of Java:
• Invented and developed Java: James Gosling, working at Sun, is credited as the
"father of Java".
• Released Java to the public in 1995, making it available for developers
worldwide.
• Promoted the concept of "Write Once, Run Anywhere", which became Java's
key advantage.
• Developed the Java Development Kit (JDK), Java Runtime Environment (JRE),
and Java APIs.
• Supported and updated Java through the 1990s and early 2000s, making it a
standard in web and enterprise application development.
• Introduced the Java Community Process (JCP), allowing developers and
organizations to contribute to the evolution of Java specifications.
Sun was known for its innovation and open-source vision, which helped Java grow into
one of the most popular languages globally.

Role of Oracle Corporation in Java Development


Oracle Corporation took over Java in 2010, and since then has been responsible for its
development, support, and licensing:
• Maintained and evolved Java: Oracle has released several new versions of Java,
including Java 7, Java 8, Java 9, and beyond.
• Improved performance and security: Java under Oracle saw performance
optimizations and better integration with modern hardware and enterprise
needs.
• Introduced new release cycle: In 2017, Oracle adopted a six-month release
cycle for Java, ensuring faster updates and innovation.
• Handled legal and licensing matters: Oracle introduced changes to the
licensing of the Oracle JDK, encouraging the use of OpenJDK for free commercial
use.
• Continued support for enterprise Java: Oracle worked with the Eclipse
Foundation to transition Java EE into Jakarta EE, an open-source project for
enterprise Java.
Oracle continues to provide long-term support (LTS) versions such as Java 8, Java 11,
and Java 17 for enterprise use.
…………………………………

14
6. JVM, JRE, and JDK
1. Java Virtual Machine (JVM)
Definition:
The Java Virtual Machine (JVM) is an abstract computing machine that enables a
computer to run a Java program. It interprets or compiles Java bytecode into machine
code so that it can be executed on the host system.
Key Features:
• Platform-independent: Java programs can run on any OS that has a JVM
installed.
• Performs runtime tasks: Memory management (via garbage collection),
security, and bytecode execution.
• It does not include development tools like compilers or debuggers.
Function:
• The JVM reads compiled .class files (bytecode) and executes them.
• It acts as the execution engine of Java.
2. Java Runtime Environment (JRE)
Definition:
The Java Runtime Environment (JRE) is a software package that provides the
libraries, Java class files, and JVM required to run Java applications.
Key Features:
• It contains:
➢ JVM
➢ Java class libraries
➢ Other files needed to run Java programs
• Does not include tools to create Java programs like the compiler (javac).
Function:
• JRE provides everything needed to execute already compiled Java programs.
• Ideal for users who only want to run Java applications, not develop them.
3. Java Development Kit (JDK)
Definition:

15
The Java Development Kit (JDK) is a full-featured software development kit used to
develop Java applications. It includes everything in the JRE plus development tools.
Key Features:
• It contains:
➢ JRE (including JVM and class libraries)
➢ Development tools: javac (Java compiler), java (launcher), javadoc, jar,
etc.
• Required for writing, compiling, debugging, and running Java code.
Function:
• JDK is used by developers to create and build Java applications.
• Once code is written and compiled into .class files, those files can be run using
JRE.
How JVM, JRE, and JDK Work Together
Let’s go through the Java program execution process:
1. Write the Java code using any text editor or IDE like IntelliJ or Eclipse.
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
2. Compile the code using the JDK (specifically, the javac compiler).
bash
javac Hello.java
This creates a bytecode file: Hello.class.
3. Execute the bytecode using the JVM, which is part of the JRE:
bash
java Hello
The JVM loads the .class file, verifies it, and translates it into machine-specific code
using the interpreter or JIT compiler, then executes it.
…………………………………

7. Strengths and Limitations of Java


16
Strengths of Java
1. Platform Independence (Write Once, Run Anywhere)
Java code is compiled into bytecode, which can run on any system that has a
Java Virtual Machine (JVM). This allows Java applications to be portable across
platforms without needing changes to the source code.
2. Object-Oriented Programming (OOP)
Java is an object-oriented language, which promotes modular programming
through concepts like classes, inheritance, encapsulation, abstraction, and
polymorphism. This leads to better code organization and reusability.
3. Rich Standard Library
Java provides a comprehensive standard library (API) that supports everything
from data structures and file handling to networking, database connectivity, GUI
development, and multithreading.
4. Robust and Secure
Java emphasizes early error checking, strong memory management through
garbage collection, and exception handling. It also includes built-in security
features such as access control, bytecode verification, and runtime restrictions.
5. Multithreaded Programming Support
Java supports multithreading, allowing the development of applications that can
perform multiple tasks simultaneously. This is essential for building high-
performance, responsive software.
6. Automatic Garbage Collection
Java handles memory management automatically through garbage collection,
which reduces the chances of memory leaks and other memory-related errors.
7. Large Community and Ecosystem
Java has a vast and active developer community, offering extensive libraries,
frameworks, tools, and learning resources. This makes development and
problem-solving more efficient.
8. Versatility and Use Cases
Java is used in a wide range of applications, including web development, mobile
apps (especially Android), enterprise software, scientific applications, and
embedded systems.
Limitations of Java
1. Performance Compared to Native Languages
Java applications are generally slower than those written in languages like C or
C++ because Java runs on the JVM, introducing an additional layer between the
code and the hardware.

17
2. Memory Consumption
Java applications require more memory compared to lower-level languages. This
is partly due to its object-oriented nature and the overhead of the JVM and
garbage collector.
3. Verbose Syntax
Java’s syntax can be lengthy and repetitive. Simple operations often require more
code in Java compared to modern languages like Python or Kotlin, which can
reduce productivity for small-scale or scripting tasks.
4. No Support for Low-Level Programming
Java does not support low-level programming tasks such as pointer
manipulation or direct hardware access. This makes it unsuitable for systems
programming or performance-critical tasks that need fine control over memory.
5. Complex GUI Development
Although Java provides GUI libraries like AWT and Swing, these are considered
outdated and less intuitive than modern frameworks available in other
languages. JavaFX is an alternative, but its adoption is limited.
6. Licensing Changes for Oracle JDK
Starting with Java 11, Oracle introduced a commercial licensing model for the
Oracle JDK. This led to concerns in the developer community and increased the
use of alternatives like OpenJDK.
…………………….The End…………………….

18

You might also like