0% found this document useful (0 votes)
3 views

1 Java Introduction

The document is an introduction to Java programming, covering its history, the significance of bytecode, and key Java buzzwords. It also provides instructions for downloading, installing, and configuring Java, as well as writing, compiling, and executing a simple 'Hello World' program. The content is structured to help students understand the fundamentals of Java programming and its applications.

Uploaded by

gohilsrushti64
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

1 Java Introduction

The document is an introduction to Java programming, covering its history, the significance of bytecode, and key Java buzzwords. It also provides instructions for downloading, installing, and configuring Java, as well as writing, compiling, and executing a simple 'Hello World' program. The content is structured to help students understand the fundamentals of Java programming and its applications.

Uploaded by

gohilsrushti64
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 57

Introduction to Java Programming

Language

Course: Programming In Java


(PRJ190901)

Lory Al Moakar
Modified By: Manishkumar R Solanki 1-1
Topic Outcomes

Students will be able to:


State the history of Java
 Discuss the importance of Bytecode
 Describe the Buzzwords of Java
 Download, Install and Configure Java
 Write, Compile and Execute a “Hello World” Java
Program

1-2
Outline

History of Java
Magic of “Bytecode”
Java Buzzwords
Downloading, Installing and Configuring Java
Writing, Compiling and Executing Hello World
Program

1-3
Java History

Computers of the past

© 2004 Pearson Addison-Wesley. All rights 1-4


Java History

The invention of the microprocessor


revolutionized computers

Intel microprocessor

Commodore Pet microcomputer

1-5
Java History
It was believed that the logical next step for
microprocessors was to have them run
intelligent consumer electronics

1-6
Java History
 A platform-independent language that could be used to
create software to be embedded in various consumer
electronic devices, such as microwave ovens and remote
controls
 C and C++ is that they are designed to be compiled for a
specific target
 A full C++ compiler targeted for a particular CPU was
required
 The compilers are expensive and time-consuming to create
 An easier—and more cost-efficient—solution was needed.
 Gosling and others began work on a portable, platform-
independent language that could be used to produce code
that would run on a variety of CPUs under differing
environments.
 This effort ultimately led to the creation of Java

1-7
Java History
Sun Microsystems funded an internal research project
“Green” to investigate opportunity to create general
language for Embedded Systems in 1991
Result: After 18 months, first working version - “Oak”

1-8
Java History(Twist)
 With the advent of the Internet and the Web, the problem
of portability returned.
 The Internet consists of a diverse, distributed universe
populated with various types of computers, operating systems,
and CPUs.
 Even though many kinds of platforms are attached to the
Internet, users would like them all to be able to run the
same program.
 What was once an irritating but low priority problem had
become a high-profile necessity.

1-9
Java History(Twist)
In 1993, this realization caused the focus of Java to switch
from consumer electronics to Internet programming
 In 1995, the team gathered to choose a new name.
The suggested words were "dynamic", "revolutionary", "Silk",
"jolt", "DNA" etc.
They wanted something that reflected the essence of the
technology: revolutionary, dynamic, lively, cool, unique, and
easy to spell and fun to say.
 Final decision was : “Java”
 Java is an island of Indonesia where first coffee was produced
(called java coffee)

1-
10
How Java Changed Internet?
Java Applets:
An applet is a special kind of Java program that is designed
to be transmitted over the Internet (downloaded) at client side
and automatically executed by a Java-compatible web
browser.
 They are typically used to display data provided by the server,
handle user input, or provide simple functions, such as a loan
calculator, that execute locally, rather than on the server

1-11
Outline

History of Java
Magic of “Bytecode”
Java Buzzwords
Downloading, Installing and Configuring Java
Writing, Compiling and Executing Hello World
Program

1-
12
Java’s Magic: The Bytecode
The output of a Java compiler is not executable
code but a bytecode i.e. .class file.
Bytecode is a highly optimized set of instructions
designed to be executed by the Java run-time
system, which is called the Java Virtual Machine
(JVM)
The original JVM was designed as an interpreter for
bytecode.
Translating a Java program into bytecode makes it
executable on a wide variety of environments. (only
the JVM needs to be implemented for each
platform.)
Java’s Magic: The Bytecode

1-
14
Java’s Magic: The Bytecode

Although the details of the JVM will differ from platform


to platform(OS specific), all understand the same Java
bytecode
If a Java program were compiled to native code, then
different versions of the same program would have to exist
for each type of CPU connected to the Internet
When a program is compiled to an intermediate form and then
interpreted by a virtual machine, it runs slower than it would
run if compiled to executable code
Because bytecode has been highly optimized, the use of
bytecode enables the JVM to execute programs much faster

1-
15
Outline

History of Java
Magic of “Bytecode”
Java Buzzwords
Downloading, Installing and Configuring Java
Writing, Compiling and Executing Hello World
Program

1-
16
Java Buzzwords

Simple
Object-oriented
Robust
Portable
Secure
Architecture-neutral
Multithreaded
Interpreted & High performance
Distributed
Dynamic

1-
17
Java Buzzwords

Simple:
If you have some programming experience, you will not find
Java hard to master
If you are an experienced C++ programmer, moving to Java
will require very little effort.
Because Java inherits the C/C++ syntax and many of the object
oriented features of C++, most programmers have little trouble
learning Java.

1-
18
Java Buzzwords

Object Oriented:

Encapsulation
Abstraction
Inheritance
Polymorphism

1-
19
Java Buzzwords
Robust:
Java is a strictly typed language, it checks your code at compile
time as well at run time.
 Memory management can be a difficult, tedious task in
traditional programming environments.
For example, in C/C++, the programmer will often manually
allocate and free all dynamic memory. This sometimes leads to
problems, if programmer forgets to free memory that has been
previously allocated.
 Deallocation is completely automatic, because Java provides
garbage collection for unused objects.
Java provides object-oriented exception handling.

1-
20
Java Buzzwords
Portability:
 Portability refers to the ability to run a program on different
machines.

The Java program is getting compiled into bytecode which


is platform independent.

For example, the same applet must can be downloaded and


executed by the wide variety of CPUs, operating systems, and
browsers connected to the Internet.

There is no need to keep different versions of the applet for


different computers. The same code must run on all computers.

1-
21
Java Buzzwords
Security:
Downloading Internet resources are prone to virus, Trojan
horse, or other harmful code.

 Java applets are confined to the Java execution


environment and are not allowed to access to other parts of
the computer i.e. partitions of the disk.

 Java doesn’t support Pointers.

1-
22
Java Buzzwords
Multithreaded:
 Multithreading means dividing a program into executable sub
programs(threads) which can run concurrently. (parallelly)
Examples:
1. On a mobile home screen : wall paper, battery level,
signal strength, location, time, etc.
2. In a browser window: different tabs
3. In a word document: writing process, printing process,
spell check process, etc.
Applications: Gaming, Animation, Networking programs

 The Java run-time system provides an elegant yet


sophisticated solution for multi threading
synchronization to develop interactive applications.

1-
23
Java Buzzwords
 Architecture-Neutral:
Operating system upgrades, processor upgrades, and changes in
core system resources do not affect the Java program
execution.

The goal in the development of Java and JVM was “write


once; run anywhere, any time, forever.”

1-
24
Java Buzzwords
Distributed:
Java is designed for the distributed environment of the Internet
because it handles TCP/IP protocols. Accessing a resource
using a URL is not much different from accessing a file.

Java also supports Remote Method Invocation (RMI). This


feature enables a program to invoke methods across a network.

1-
25
Java Buzzwords
 Dynamic:
 It supports dynamic loading of classes.(classes are loaded on
demand.)

 Java programs carry with them substantial amounts of run-


time type information that is used to verify and resolve
accesses to objects at run time.

 It also supports functions from its native languages, i.e., C and


C++.

1-
26
Outline

History of Java
Magic of “Bytecode”
Java Buzzwords
Downloading, Installing and Configuring Java
Writing, Compiling and Executing Hello World
Program

1-
27
Downloading Java
URL: : http://www.oracle.com/technetwork/java/javase/downloads/index.html

1-
28
Downloading Java

1-
29
Installing Java

1-
30
Installing Java

https://www.guru99.com/install-java.html

1-
31
Installing Java

1-
32
Configuring Java [Setting PATH]
Step 1) Right Click on the My Computer and Select the properties

1-
33
Configuring Java [Setting PATH]
Step 2) Click on advanced system settings

1-
34
Configuring Java [Setting PATH]
Step 3) Click on Environment Variables

1-
35
Configuring Java [Setting PATH]
Step 4) Click on new Button of User variables

1-
36
Configuring Java [Setting PATH]
Step 5) Type PATH in the Variable name

Step 6) Copy the path of bin folder which is installed in JDK


folder.

1-
37
Configuring Java [Setting PATH]
Step 7) Paste Path of bin folder in Variable value and click on OK
Button.

1-
38
Configuring Java [Setting PATH]
Step 8) Click on OK button

1-
39
Configuring Java [Setting PATH]
Step 9) Go to command prompt and type javac commands.
If you see a screen like below, Java is installed and PATH is set

1-
40
Configuring Java
To see the version of Java installed : java -version

1-
41
Outline

History of Java
Magic of “Bytecode”
Java Buzzwords
Downloading, Installing and Configuring Java
Writing, Compiling and Executing Hello World
Program

1-
42
Java Program Structure

In the Java programming language:


◦ A program is made up of one or more classes
◦ A class contains one or more
methods(functions)
◦ A method contains program statements

AJava application always contains a


method called main()
A Java Applet doesn’t contain main()

1-
43
Text Editors to write a Java Program

1-
44
IDEs to write a Java Program

1-
45
Writing “Hello World” Java Program

HelloWorld.java
class HelloWorld
{
public static void main (String args[])
{
System.out.println (“Hello World");
}
}

Note: Save the file with the name of class inside which
main( ) resides

1-
46
Java Program Structure

// comments about the class


class HelloWorld
{
class header

class body

Comments can be placed almost anywhere


}

1-
47
Java Program Structure

class HelloWorld
{

// comments about the method


public static void main (String args[])
{
method header
method body
}

1-
48
Comments
 Comments in a program are called inline
documentation
 They should be included to explain the purpose
of the program and describe processing steps
 They do not affect how a program works
 Java comments can take three forms:

// this comment runs to the end of the line

/* this comment runs to the terminating


symbol, even across line breaks */

/** this is a javadoc comment */

1-
49
Compiling “Hello World” Java Program
 Open Command Prompt
 Make a directory (inside which java programs
are residing) as working/present directory
 Compile the program with javac program.java

1-
50
Executing “Hello World” Java Program
 After successfully compilation of
program .class file (bytecode) is generated
 To execute, we have to write : java
filename command

1-
51
Java Ecosystem

https://www.geeksforgeeks.org/differences-jdk-jre-jvm/
1-
52
JVM
 JVM (Java Virtual Machine) is an abstract
machine. It is called virtual machine because it
doesn't physically exist.
 It is a specification that provides runtime
environment in which java bytecode can be
executed
 JVMs are available for many hardware and
software platforms. JVM, JRE and JDK are
platform dependent because configuration of
each OS are different from each other
 Functions of JVM:
 Loads code
 Verifies code
 Executes code
 Provides runtime environment 1-
53
JRE
 JRE is an acronym for Java Runtime
Environment
 It is also written as Java RTE.
 The Java Runtime Environment is a set of
software tools which are used for developing
java applications
 It is used to provide runtime environment. It is
the implementation of JVM
 It physically exists.
 It contains set of libraries + other files that
JVM uses at runtime

1-
54
JDK
 The Java Development Kit (JDK) is a software
development environment which is used to
develop java applications and applets.
 It physically exists.
 It contains JRE + development tools(i.e.
javac,java,jar,etc.)
 JDK is an implementation of any one of the
below given Java Platforms released by Oracle
corporation:
Standard Edition Java Platform
Enterprise Edition Java Platform
Micro Edition Java Platform

1-
55
Credits

• Lory Al Moakar,2004 Pearson Addison-Wesley.


• https://specialties.bayt.com/en/specialties/q/223774/why-
java-is-considered-dynamic/

1-
56
You can find me at:
[email protected]
m

You might also like