Download Intro to Java

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
CSCI 224
Introduction to Java Programming
Course Objectives
 Learn the Java programming language:
 Syntax, Idioms
 Patterns, Styles
 Become comfortable with OOP
 Learning to think in objects
 Learn the essentials of the Java class library
 And how to learn about other parts when you
need them
Writing Code
 It is not enough to write code that
works.
 It is important to write code that is
also
Legible, Maintainable,
Reusable, Fast and
Efficient
Java
 Sun defines Java as a:
“…simple, object-oriented, network
savvy, interpreted, robust, secure,
architecture-neutral, portable, highperformance, multi-threaded, dynamic
language.”
What is Java?
 History of Java
 First started in 1990 as Sun’s Green project
 Digitally controlled consumer devices identified as
trend
 Trend did not grow as expected
 1994 – WWW popularity
 Netscape packaged Java within browser
 - MS Explorer followed suit
 Success ultimately depended on e-commerce
What is Java
 Java is a high level,third generation
programming language
 Compared to other languages it is
most similar to C and shares much of
the syntax
 Unlike C++ Java is not a superset of C
and substantial amounts of C code
would need to be reworked to become a
Java program
Java is :








A Platform
Simple
Object-Oriented
Platform independent
Safe
High Performance
Multi-Threaded
Garbage Collected
Platform
 Three elements to Java
 The programing language
 The compiler
 The Java interpreter
 The Java compiler creates byte code and not
code native to particular platform. The
result is that the JVM the runtime machine
interprets this code on the fly and translates
it to the machine.
Simple
 Java is designed to be easy to write.
 Not a lot of special tricks to confuse
beginners
 Memory allocation and deallocation are
handled automatically.
 Syntax is straight forward in most
situations.
Object Oriented
 The core concept of Java
 Everything is an object.
 Huge libraries of objects are available.
 Learning to use the API is essential
Platform independent
 The Java byte code is never really
executed on the host machine.
 Each JRE / JVM does all the work of
interfacing with the OS and machine.
 Also eliminates having to deal with
variations in platform architecture
 Integer is always four bytes.
Safe
 Java was designed from the ground up
to allow for execution across a
network.
 Applets – executed with set limitations
on what they can do to within your
system. Essentially they run in a
sandbox.
High Performance
 The Java byte code compiles on the fly
with speeds that rival the C++
compiler.
Multi-Threaded
 Java is inherently multi-threaded
allowing a single program to execute
different processes independently and
continuously.
 The is a cost to this for the
programmer. Just as in C pointer
arithmetic can be hard to debug,
debugging threads is a challenge.
Garbage Collection
 There is no need to explicitely allocate
or de-allocate memory in Java.
 No need to write destructor methods.
 The JRE handles the trash.
Practical
 What do you need to run Java.
 JDK – Java developer's Kit.
 JRE – Java Runtime Enviroment
 SDK – Java Software Development Kit
 IDEs
 Several development tools exist.
 The most basic thing you need is Notepad or
any text editor to write the java source files.
 Jbuilder, Sun's One Studio , JCreator,
Forte and Eclipse are just a few.
Development Tools
 1995 – First JDK released by Sun (1.0)
 Very limited
 JDK 1.1 released
 Limited GUI creation
 1.2 released
 Major change – Swing components
 Java 2 SDK release 1.2
 Better known as Java 2
 Most current version: 1.5
Development Tools
 Java 2 Editions
 Java 2 Platform, Standard Edition
 Java 2 Platform, Enterprise Edition
 Java 2 Platform, Micro Edition
Java Programs
 Applets
 Java program running within client Web
browser
 Servlet
 Java program running on a server
 Can ‘cooperate’ with applet or
application
 Application
 Standalone program