Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
82 views

Java Programming Introduction

1) The document introduces Java programming and its history. It discusses how Java enables applications to run on servers, desktops, and devices through bytecode that runs on the Java Virtual Machine (JVM). 2) It summarizes the evolution of Java from low-level machine languages to high-level languages like Java. It also outlines some key aspects of Java programs like classes, methods, and the main method. 3) The document provides an overview of Java development kits (JDKs) and editions like Java Standard Edition (J2SE) used to develop desktop apps, and Java Micro Edition (J2ME) for mobile apps. It also demonstrates a simple Java program and compilation process.

Uploaded by

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

Java Programming Introduction

1) The document introduces Java programming and its history. It discusses how Java enables applications to run on servers, desktops, and devices through bytecode that runs on the Java Virtual Machine (JVM). 2) It summarizes the evolution of Java from low-level machine languages to high-level languages like Java. It also outlines some key aspects of Java programs like classes, methods, and the main method. 3) The document provides an overview of Java development kits (JDKs) and editions like Java Standard Edition (J2SE) used to develop desktop apps, and Java Micro Edition (J2ME) for mobile apps. It also demonstrates a simple Java program and compilation process.

Uploaded by

wasik mahir
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Introduction to Java

Rajesh Palit, Ph.D.


Electrical and Computer Engineering
North South University

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Computer Programming

• A computer program is a set of instructions to the computer


telling it what to do. Programming is the creation of a program
executable by a computer and performs the required tasks
• Computers do not understand human languages, so we need to
use computer languages in computer programs
• A computer’s native language is a set of built-in primitive
instructions. The instruction set is in the form of binary code and
differs among different types of computers
• Programming in machine language is a tedious process. Moreover,
the programs are highly difficult to read and modify
• To add two numbers, we might have to write an instruction in
binary like this 1101101010011010

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Assembly Language
• Assembly language is a low-level programming language in
which a mnemonic is used to represent each of the machine
language instructions. For example, to add two numbers, we
might write an instruction in assembly code like this: ADDF3 R1,
R2, R3
• Since the computers cannot understand assembly language, a
program called an assembler is used to convert assembly-
language programs into machine code

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
High Level Programming Languages
• As program size grows, assembly program becomes
unmanageable
• The high-level languages are English-like and easy to learn and
program. Here, for example, is a high-level language statement
that computes the area of a circle with radius 5: area = 5
* 5 * 3.1415;

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Prominent High Level Programming
Languages
COBOL (COmmon Business Oriented Language)
FORTRAN (FORmula TRANslation)
BASIC (Beginner’s All-purpose Symbolic Instruction Code)
Pascal (named for Blaise Pascal)
Ada (named for Ada Lovelace)
C (developed by the designer of B)
Visual Basic (Basic-like visual language by Microsoft)
Delphi (Pascal-like visual language developed by Borland)
C++ (an object-oriented language, based on C)
C# (a Java-like language developed by Microsoft)
Java
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Why Java?

 The answer is that Java enables users to develop and deploy


applications on the Internet for servers, desktop computers,
and small hand-held devices
 The future of computing is being profoundly influenced by
the Internet, and Java promises to remain a big part of that
future. Java is the Internet programming language
 Java is a general purpose programming language as well as
the Internet programming language
 Java is purely Object Oriented Programming Language

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
History of Java

• James Gosling, Mike Sheridan, and Patrick Naughton


initiated the Java language project in June 1991 in Sun
Microsystem
• Java was originally designed for interactive television, but it
was too advanced for the digital cable television industry at
the time
• The language was initially called Oak after an oak tree that
stood outside Gosling's office
• It went by the name Green later, and was later renamed
Java, from Java coffee said to be consumed in large
quantities by the language's creators
• Public in Sun World: May 20, 1995

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Java Development Kit (JDK) Versions

• JDK 1.02 (1995)


• JDK 1.1 (1996)
• JDK 1.2 (1998)
• JDK 1.3 (2000)
• JDK 1.4 (2002)
• J2SE 5 (2004), internal version 1.5 or Java 5
• J2SE 6 (2006), internal version 1.6 or Java 6
• J2SE 7 (2011)
• J2SE 8 (2014)
• Java 2 Platform, Standard Edition 12 (March 2019)

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
JDK Editions

• Java Standard Edition (J2SE)


• J2SE can be used to develop client-side standalone
applications or applets.
• Java Enterprise Edition (J2EE)
• J2EE can be used to develop server-side applications such as
Java servlets and Java ServerPages.
• Java Micro Edition (J2ME).
• J2ME can be used to develop applications for mobile devices
such as cell phones.
• This book uses J2SE to introduce Java programming.

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Application Program and Operating Systems
(OS)
• The operating system(OS) is the
most important program that runs
on a computer, which manages
and controls a computer’s
activities
• OS abstracts the hardware from
the users
• Users do not need to know the
details of the HW
• Using application programs such
as a web browser or a word
processor, users utilize hardware
components through OS
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
• Write a program
• Compile the program
• Hello.c => compiler => hello.exe
• Hello.exe => Windows 10
byte code

• hello.java
• hello.java => javac => hello.class [is not directly executable on OS]
• hello.class => Java Virtual Machine (software machine on top of
machine)

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All 11
rights reserved. 0132130807
• hello.c => after compilation => hello.exe -- execute (Windows)
• hello.c - after compilation  hello.out  execute (Linux)

• hello.java  compile  hello.class  execute anywhere where there


is JVM

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All 12
rights reserved. 0132130807
Java Program Execution

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Java Bytecode and JVM

 Java source file using any text


editor such as Eclipse, NetBeans,
TextPad or Notepad++
 Compile the source codes javac
source.java, and execute java
source
 Integrated Development
Environment (IDE): Netbeans /
Eclipse
 JVM for every platform
 Compile once, run anywhere
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
A Sample Java Program

//This program prints Welcome to Java!


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

• The name of the source file must be Welcome.java


• This program prints: Welcome to Java!

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Anatomy of a Java Program
• Comments
• Reserved words
• Modifiers
• Statements
• Blocks
• Classes
• Methods
• The main method

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Smallest Java Program

public class Smallest


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

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807
Integrated Development Environment (IDE)

• Eclipse
• Command Prompt
• javac program_name.java
• Java program_name

Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All
rights reserved. 0132130807

You might also like