Chapter 1
Chapter 1
Deena Sitikhu
2026 CSIT DWIT
Introduction
● Java is a programming language as well as a platform.
● Java is a general purpose, object-oriented and network-centric language
designed for having lesser implementation dependencies.
Features
● It is one of the easy-to-use programming languages to learn.
● Write code once and run it on almost any computing platform.
● Java is platform-independent. Some programs developed in one machine can
be executed in another machine.
● It is designed for building object-oriented applications.
● It is a multithreaded language with automatic memory management.
● It is created for the distributed environment of the Internet.
● Facilitates distributed computing as its network-centric.
Usage
● It is used for developing Android Apps
● Helps you to create Enterprise Software
● Wide range of Mobile java Applications
● Scientific Computing Applications
● Use for Big Data Analytics
● Java Programming of Hardware devices
● Used for Server-Side Technologies like Apache, JBoss, GlassFish, etc.
History of Java Programming Language
Here are important landmarks from the history of the Java language:
● The Java language was initially called OAK and built at Sun Microsystems,
Inc. in 1991.
● Originally, it was developed for handling portable devices and set-top boxes.
Oak was a massive failure.
● In 1995, Sun changed the name to “Java” and modified the language to take
advantage of the growing www (World Wide Web) development business.
● Later, in 2009, Oracle Corporation acquired Sun Microsystems and took
ownership of three key Sun software assets: Java, MySQL, and Solaris.
Java Compiling and Interpreting process
Components of Java Programming Language
● A Java Programmer writes a program in a human-readable language called Source Code.
Therefore, the CPU or Chips never understand the source code written in any programming
language.
● These computers or chips understand only one thing, which is called machine language or code.
These machine codes run at the CPU level. Therefore, it would be different machine codes for
other models of CPU.
● However, you need to worry about the machine code, as programming is all about the source code.
The machine understands this source code and translates them into machine understandable code,
which is an executable code.
● All these functionalities happen inside the following 3 Java platform components
Components of Java Programming Language
1. Java Development Kit (JDK)
2. Java Runtime Environment (JRE)
3. Java Virtual Machine (JVM)
1. Java Development Kit
● JDK is a software development environment used for making applets and
Java applications.
● Java developers can use it on Windows, macOS, Solaris, and Linux.
● JDK helps them to code and run Java programs.
● It is possible to install more than one JDK version on the same computer.
● JDK contains tools required to write Java programs and JRE to execute them.
● It includes a compiler, Java application launcher, Appletviewer, etc.
● Compiler converts code written in Java into byte code.
● Java application launcher opens a JRE, loads the necessary class, and
executes its main method.
2. Java Virtual Machine
● JVM is an engine that provides a runtime environment to drive the Java Code
or applications.
● It converts Java bytecode into machine language.
● JVM is a part of the Java Run Environment (JRE).
● In other programming languages, the compiler produces machine code for a
particular system. However, the Java compiler produces code for a Virtual
Machine i.e. Java Virtual Machine.
● JVM provides a platform-independent way of executing Java source code.
● It has numerous libraries, tools, and frameworks.
● Once you run a Java program, you can run on any platform and save lots of
time.
● JVM comes with JIT (Just-in-Time) compiler that converts Java source code
into low-level machine language. Hence, it runs faster than a regular
application.
3. Java Runtime Environment
● JRE is a piece of software that is designed to run other software.
● It contains the class libraries, loader class, and JVM. In simple terms, if you
want to run a Java program, you need JRE.
● If you are not a programmer, you don’t need to install JDK, but just JRE to run
Java programs.
● JRE contains class libraries, JVM, and other supporting files. It does not
include any tool for Java development like a debugger, compiler, etc.
● It uses important package classes like math, swing, util, lang, awt, and
runtime libraries.
● If you have to run Java applets, then JRE must be installed in your system.
Assembler and Compiler
Assembler converts Assembly Language into Binary code.
Compiler converts long source code into small chunks of assembly code.
● As a developer, I want my software program to work on all platforms to maximize my
revenues. So I would have to buy separate compilers that convert my print f command into
the native machine code.
● But compilers come expensive, and there is a chance of compatibility issues.
So buying and installing a separate compiler for different OS and processor is
not feasible. So, what can be an alternative solution? Enter Java language.
How Java Virtual Machine works?
● By using Java Virtual Machine, this problem can be solved. But how it works on
different processors and O.S.
Step 1) The code to display the addition of two numbers is System.out.println(1+2), and saved as
a .java file.
Step 2) Using the java compiler the code is converted into an intermediate code called the
bytecode. The output is a .class file.
Step 3) This code is not understood by any platform, but only a virtual platform called the Java
Virtual Machine.
Step 4) This Virtual Machine resides in the RAM of your operating system. When the Virtual
Machine is fed with this bytecode, it identifies the platform it is working on and converts the
bytecode into the native machine code.
What makes Java lucrative is that code, once compiled, can run not only on all PC platforms but
also on mobiles or other electronic gadgets supporting Java.
● Like the C compiler, the Java compiler does not produce native executable
code for a particular machine.
● Bytecode is understandable to any JVM installed on any OS. In short, the java
source code can run on all operating systems.
Platform Dependency Concept