0% found this document useful (0 votes)
2 views33 pages

Lecture1 JavaEnvironment

Intro to java programming environment

Uploaded by

defaltccc
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)
2 views33 pages

Lecture1 JavaEnvironment

Intro to java programming environment

Uploaded by

defaltccc
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

Java Fundamentals

Introduction to Java and


programming environment
Lecture 1
Objectives
Java Fundamentals

At the end of the lesson, the student should be able to:

 Describe the features of Java technology such as the Java virtual


machine, garbage collection and code security

 Describe the different phases of a Java program.

 Write compile and run Java programs using a console and a text
editor and using an Integrated Development Environment or
IDE (Eclipse, Jcreater, BlueJ)

 Differentiate between syntax-errors and runtime errors

8/16/2022 2
Topic & Structure of the lesson
Java Fundamentals

1. What is Java Technology


2. Language features
3. Java and The Internet
4. How Java differs from the C/C++ language
5. Applets and Applications
6. The Java Development Kit (JDK)
7. A Simple Java Program

8/16/2022 3
What is Java Technology?
Java Fundamentals

A programming language
 As a programming language, Java can create all
kinds of applications that you could create using any
conventional programming language.

A development environment
 As a development environment, Java technology
provides you with a large suite of tools: a compiler, an
interpreter, a documentation generator, a class file
packaging tool, and so on.

8/16/2022 4
What is Java Technology?
Java Fundamentals
An application environment
Java technology applications are typically general-purpose
programs that run on any machine where the Java runtime
environment (JRE) is installed.

A deployment environment
There are two main deployment environments: First, the JRE
supplied by the Java 2 Software Development Kit (SDK) contains the
complete set of class files for all the Java technology packages, which
includes basic language classes, GUI component classes, and so on. The
other main deployment environment is on your web browser. Most
commercial browsers supply a Java technology interpreter and runtime
environment.

8/16/2022 5
Key Terms you must be able to use
Java Fundamentals

If you have mastered this topic, you should be able to use


the following terms correctly in your assignments and
exams:

Application - A complete, self-contained program that


performs a specific function directly for the user.

Applet - A Java program which can be distributed as an


attachment in a World-Wide Web document and executed
by a Java-enabled web browser such as Sun's HotJava,
Netscape Navigator version 2.0, or Internet Explorer.

8/16/2022 6
Key Terms you must be able to use
Java Fundamentals

If you have mastered this topic, you should be able to use


the following terms correctly in your assignments and
exams:

Platform - the hardware / software environment in which a


program runs.

Java platform - a software-only platform that runs on top of


other, hardware-based platforms.

8/16/2022 7
Key Terms you must be able to use
Java Fundamentals

Java Virtual Machine (Java VM)

• A virtual CPU including instruction set, register


set, class file format, stack, garbage collected
memory heap & memory area

• Every Java interpreter, whether it’s a Java


development tool or a Web browser that can run
Java applets is an implementation of Java VM.

8/16/2022 8
Key Terms you must be able to use
Java Fundamentals

Java Application Programming Interface (Java API)

• A large collection of ready-made software


components that provide many useful capabilities
such as graphical user interface (GUI) widgets.

• The Java API is grouped into libraries (packages) of


related components

8/16/2022 9
What is Java?
Java Fundamentals

Let’s examine what Java is in terms of

• Language comparison

• Platform independence

• Language features

8/16/2022 10
What is Java?
Java Fundamentals

Beginning

SmallTalk C++
First true OO Language. Powerful systems language.
Secure type-checking. Familiar to many programmers.

JAVA
( Combines the best of both, leaving out the difficulties)

8/16/2022 11
What is Java?
Java Fundamentals

Platform Independence

JAVA

Programming
Platform
Language

8/16/2022 12
What is Java?
Java Fundamentals

Language features
Java is a High-Level Programming Language that is :
Simple
- powerful functionality without the confusing features(eg.
pointers)
- reduce 50 % of the bugs

Objected oriented
- implements the basic object technology of C++ with
enhancement

Distributed
- built-in extensive TCP/IP networking capabilities
8/16/2022 13
What is Java?
Java Fundamentals

Language features
Java is a High-Level Programming Language that is :

Robust
- check for problems at compile and run-time - help
catch the bugs at the early stage of development
- handles own memory - no worries on freeing &
corrupting memory
- reduce development time

Secure
- Java codes passes several tests before executing
on machine
- eg. Byte-code verifier, class loader
8/16/2022 14
What is Java?
Java Fundamentals

Language features
Java is a High-Level Programming Language that is :

Multithreaded
- threads - light-weighted processes
- allows many simultaneous activities in 1 program

Portable
- basic portability of being architecture neutral / independent
- Java builds its user interfaces via an abstract window
system so the windows can be implemented on UNIX, PC
& MAC environments

8/16/2022 15
What is Java?
Java Fundamentals

Language features
Java is a High-Level Programming Language that is :

Architecture Neutral (Special Feature)


• both compiled and interpreted

• with compiler, a Java program is translated into Java


bytecodes

• with interpreter,each Java bytecode instruction is parsed


and run on computers

8/16/2022 16
What is Java?
Java Fundamentals

Architecture Neutral (Special Feature)

Java Bytecodes - machine code instructions for the


Java Virtual Machine (Java VM).

8/16/2022 17
What is Java?
Java Fundamentals

Architectural Neutral + Portble (abstract window)

”Write Once, Run Anywhere - Platform Independent”

8/16/2022 18
What is Java?
Java Fundamentals

Platform - the hardware / software environment in which a


program runs.

Java platform - a software-only platform that runs on top of


other, hardware-based platforms.
The Java platform has 2 components :

1. The Java Virtual Machine (Java VM)


2. The Java Application Programming Interface (Java API)
What is Java?
Java Fundamentals

Java Virtual Machine (Java VM)


• A virtual CPU including instruction set, register
set, class file format, stack, garbage collected
memory heap & memory area
• Every Java interpreter, whether it’s a Java
development tool or a Web browser that can run
Java applets is an implementation of Java VM.

8/16/2022 20
What is Java?
Java Fundamentals

Java Application Programming Interface (Java API)


• A large collection of ready-made software
components that provide many useful capabilities
such as graphical user interface (GUI) widgets.
• The Java API is grouped into libraries (packages) of
related components

8/16/2022 21
Java and The Internet
Java Fundamentals

• Java is becoming a computing platform-base for


software developers to build applications
• these applications can execute on any computing
platform
• a variety of applications can be built eg. critical
applications used by big companies, accounting, asset
management, databases, human resources and sales

8/16/2022 22
How Java differs from C
Java Fundamentals

• No preprocessor
Java does not require constructs such as #define,
#include, and #ifdef

• No pointers
referencing and dereferencing of objects are
handled automatically by JAVA

8/16/2022 23
How Java differs from C
Java Fundamentals

• No multiple inheritances
JAVA does not support multiple inheritances, features
of multiple inheritance are supported in the form of
interfaces
• Garbage Collection
in C you need to make explicit calls to malloc() to
allocate memory. Use free() to deallocate memory.
In Java, there is a new keyword, but no delete. Objects
are implicitly deleted when they go out of scope or are
no longer needed.
Note : There are many more differences between
JAVA and C

8/16/2022 24
Applets and Applications
Java Fundamentals

The most common types of Java programs are :

• Applets
- A Java program that adheres to certain conventions
that allow it to run within a Java-enabled web
browser.
• Applications
- A standalone Java program that runs directly on a java
platform.
- As Java is a general purpose, high-level programming
language and a powerful software platform, we can
write many types of programs.

8/16/2022 25
The Java Development Kit (JDK)
Java Fundamentals

The JDK contains what one needs to start building and


executing JAVA applications and applets.

8/16/2022 26
The Java Development Kit (JDK)
Java Fundamentals
Here is how you can set up and program in Java
1. Download the Java Development Kit (JDK)
[Link]
oads/[Link]

2. Download/bookmark the Java API Documentation

[Link]
nloads/[Link]
3. Download/bookmark the Java Tutorial

[Link]

8/16/2022 27
JAVA Editors and IDEs
Java Fundamentals

 Eclipse. Free, open-source IDE. The most popular of the Java IDEs, but
harder to set up and configure than the commercial ones
 Borland JBuilder. Borland JBuilder is a Java IDE for Windows, Solaris,
and Linux. They offer a few different JBuilder versions:
 TextPad TextPad is a powerful programming editor with good modes
for Java, HTML, JSP, C, C++, and many other languages.
 UltraEdit. Another editor with an excellent Java mode. Can be set up to
compile and run Java programs directly from the editor

8/16/2022 28
Phases of a Java Program
Java Fundamentals

8/16/2022 29
Summary of Phases of a Java Program
Java Fundamentals

Task Tool to use Output


Write the program Any text editor File with .java
extension
Compile the program Java Compiler File with .class
extension
(Java bytecodes)
Run the program Java Interpreter Program Output

8/16/2022 30
Writing the first Java Application
Java Fundamentals

8/16/2022 31
Quick Review Question
Java Fundamentals

Here are a couple quick questions before we plunge into our


first Java program.

1. What is the difference between an applet and an application?

2. Does an application need the JVM for execution?

3. Does an applet need the JVM for execution?

4. Does a browser need the JVM for executing Java applets?

5. Can Java run on Machine? What is needed to run java


on a computer
8/16/2022 32
Question and Answer Session
Java Fundamentals

Q&A

8/16/2022 33

You might also like