Introduction to Java
Maiwand University
Faculty of Computer Science
Chapter 2
Lecturer: Ajmal Sahak
May 2025
Contents
• Introduction to Java
• Java History
• Main Properties of Java
• Java Platform
• Compilation and Interpretation in Java
• Java Virtual Machine (JVM)
• Java Runtime Environment
• Java Development Kit
• Java Integrated Development Environment (IDE)
Introduction to Java
• Java is widely used object-oriented programming language across the
globe.
• It is one of the most widely used object-oriented programming languages
and it runs on Android phones, tablets, TVs, cars, wearables, desktops,
laptops, and servers
• It is backed by a vast library set, active community, and robust
development tools (e.g., IntelliJ, Eclipse)
• Enables development of:
Desktop applications
Web applications and services
Android apps
• Supports various platforms:
Android phones, tablets, TVs, cars, and wearables
Desktop, laptop, and server systems
Meets the needs of nearly every industry today
Java History
• 1991: Java was developed by James Gosling at Sun Microsystems.
• Initially called Oak, it was renamed Java after discovering the name "Oak"
was already in use. The name was inspired by the coffee the developers
drank.
• 1995: First public release as Java 1.0, promoting the "write once, run
anywhere" philosophy.
• 2006: Java was made open-source under the GNU General Public License.
• 2010: Oracle Corporation acquired Sun Microsystems and took over Java’s
development.
• Java is now maintained through the OpenJDK project.
• Java 8 remains widely used, while Java 17 and Java 21 offer enhanced
features and Long-Term Support (LTS).
Main Properties of Java
• Object-oriented programming: Everything (except primitive types) is
treated as an object
• Platform-independent: Runs on the Java Virtual Machine (JVM), enabling
"write once, run anywhere“
• Robust and secure: Strong memory management and exception handling
minimize runtime errors
• Automatic memory management: Garbage Collector cleans unused
objects to prevent memory leaks
• Multithreading support: Allows multiple tasks to run concurrently for
better performance
• Simplified syntax: Avoids complex features like pointers and multiple
inheritance found in C++
• Distributed computing support: Java applications can be spread across
networks, including the internet
• Compiled and interpreted: Source code is compiled to platform-
independent bytecode, then interpreted or JIT-compiled by the JVM
Java Platform
• Java is not just a programming language but also a full software platform
• Provides standardized services across all operating systems
Enables true platform independence
• The Java platform allows software to run on a wide range of devices
From desktops to mobile and embedded systems
• Java programming language is used to build applications on this platform
Development tools and environments are freely available
• How Java programs run:
Developer writes Java code
Code is compiled into bytecode using a Java compiler
Bytecode runs on any system via the Java Virtual Machine (JVM)
JVM executes bytecode by interpreting it or using Just-In-Time (JIT)
compilation
Compilation and Interpretation in Java
• Source code is human-readable code written in a programming language.
In Java, source files have the .java extension
• Computers only understand binary (machine code), so source code must
be converted.
• There are two methods of converting source code to machine code:
• Compilation
Entire program is translated into machine code before execution
Produces an independent, executable file
Faster execution but requires re-compilation after changes
Used by languages like C, Pascal, Ada
• Interpretation
Code is translated and executed line-by-line during runtime
Slower, but allows instant testing and flexibility
Used by languages like Python, Ruby, Perl
• Java uses both: Source code is compiled to bytecode and Bytecode is
interpreted or compiled at runtime by the Java Virtual Machine
(JVM)behaviors.
Java Virtual Machine (JVM)
• Java is both a compiled and interpreted programming language
• Java source code is compiled into bytecode, saved in .class files
• Bytecode is an intermediate language understood by the Java Virtual
Machine (JVM)
• JVM runs bytecode on any operating system, enabling platform
independence
• JVM interprets or compiles bytecode into native machine code during
program execution
• Java's platform independence is made possible by the JVM, supporting the
"write once, run anywhere" principle
• Just-in-Time (JIT) compilers in modern JVMs (like HotSpot) improve
execution speed by compiling bytecode on the fly
• Early performance issues with bytecode execution led to the development
of JIT tools
• JVM also supports other languages like Scala, Groovy, and JRuby by
running their compiled bytecode
Java Runtime Environment
• JRE is required to run any program written in the Java programming
language
• It includes the Java Virtual Machine (JVM) and core Java libraries needed
for execution
• JRE provides the minimum environment necessary to run Java applications
• Devices must have JRE installed to execute Java programs
• JRE installation is typically a one-time setup per device
• Some operating systems include JRE by default, while others require
manual installation
• Once installed, JRE allows Java applications to run without needing to
reinstall it for each new program
Java Development Kit
• JDK is a package containing essential tools for Java software development
• Free to download and use
• Includes the Java Runtime Environment (JRE), which is necessary for
running Java programs
• JDK contains a Java Compiler, Java Interpreter, development tools, and
additional libraries
• Designed for developers, providing extra libraries, documentation, and
tools for creating Java applications
• JDK also includes Java API for various functionalities like disk, graphics,
network, database, and security access
• Available for download at Oracle JDK download page
Java Integrated Development Environment (IDE)
• IDEs help developers write Java source code efficiently and error-free
• Java source code requires specific syntax and rules, which are supported
by IDEs
• IDEs improve productivity by offering helpful features like syntax
highlighting and error reminders
• Essential IDE features include:
Syntax highlighting tailored to the programming language
Real-time project structure visualization
Integrated compiler, interpreter, and debugger
Build tools for compiling, linking, and preparing software
• Key IDEs for Java development are Eclipse, IntelliJ IDEA, NetBeans,
JDeveloper, BlueJ, and JCreator.
Thank You