Download Java set 1

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

Java syntax wikipedia , lookup

Falcon (programming language) wikipedia , lookup

Abstraction (computer science) wikipedia , lookup

Reactive programming wikipedia , lookup

Functional programming wikipedia , lookup

Class (computer programming) wikipedia , lookup

Library (computing) wikipedia , lookup

Go (programming language) wikipedia , lookup

Compiler wikipedia , lookup

Name mangling wikipedia , lookup

Programming language wikipedia , lookup

Scala (programming language) wikipedia , lookup

Object-oriented programming wikipedia , lookup

Structured programming wikipedia , lookup

Java (programming language) wikipedia , lookup

C Sharp (programming language) wikipedia , lookup

Java performance wikipedia , lookup

Transcript
Java Environment (CSS444)
•
•
•
•
•
•
•
•
Introduction
Object Oriented Programming Concepts
Basics for Java Applications
Basics for Java Applets
Control Structures
Methods
Arrays
Object Oriented Programming
• Inheritance, Superclasses, Subclasses, Polymorphism, Abstract and
concrete classes
•
•
•
•
Strings and Characters
Exception Handling
Files and Streams
Java Database Connectivity
Chapter 1 - Introduction to Computers,
the Internet, and the World Wide Web
Outline
1.1 Introduction
1.3 Computer Organization
1.4 Evolution of Operating Systems
1.5 Distributed and Client/Server Computing
1.6 Machine Languages, Assembly Languages and High-Level
Languages
1.8 History of Java
1.9 Java Class Libraries
1.10
Other High-Level Languages
1.11
Structured Programming
1.13
Basics of a Typical Java Environment
1.14
General Notes about Java and This Book
1.1
Introduction
• Java
– Powerful, object-oriented language
– Fun to use for beginners, appropriate for experienced
programmers
– Language of choice for Internet and network
communications
– Free implementation at http://java.sun.com
1.3 Computer Organization
• Six logical units in every computer
• Input unit
• Gets information from input devices (keyboard, mouse)
• Output unit
• Gets information (to screen, to printer, to control other devices)
• Memory unit
• Rapid access, low capacity, stores input information
• Arithmetic and logic unit (ALU)
• Performs arithmetic calculations and logic decisions
• Central processing unit (CPU)
• Supervises and coordinates the other sections of the computer
• Secondary storage unit
• Cheap, long-term, high-capacity storage, stores inactive
programs and data
1.4
Evolution of Operating Systems
• Batch processing
– Do only one job or task at a time
• Operating systems
– Manage transitions between jobs
– Increased throughput - amount of work computers process
• Multiprogramming
– Many jobs or tasks sharing the computer resources
• Timesharing
– Runs a small portion of one user’s job then moves on to service the
next user
– Programs appear to be running simultaneously
1.5
Distributed and Client/Server
Computing
• Distributed computing
– Organization has a Local Area Network (LAN)
• Computers linked to it
– Computing distributed over the LAN, rather than at one
central location
1.5
Distributed and Client/Server
Computing
• Client/Server computing
– File servers offer common store of programs that client
computers access
– C and C++ popular for writing operating systems,
networking, and distributed client/server applications
– Java used for Internet-based applications
1.6 Machine Languages, Assembly
Languages and High-Level Languages
• Types of programming languages
1. Machine languages
– Strings of numbers giving machine specific instructions
– Example:
+1300042774
+1400593419
+1200274027
2. Assembly languages
– English-like abbreviations representing elementary computer
operations (translated via assemblers)
– Example:
LOAD
BASEPAY
ADD
OVERPAY
STORE GROSSPAY
1.6 Machine Languages, Assembly
Languages and High-Level Languages
• Types of programming languages
3.
High-level languages
– Similar to everyday English and use mathematical notations
(translated via compilers)
– Example:
grossPay = basePay + overTimePay
1.8
History of Java
• Java
– Based on C and C++
– Originally developed in early 1991 for intelligent consumer
electronic devices
• Market did not develop, project in danger of being cancelled
– Internet exploded in 1993, saved project
• Used Java to create web pages with dynamic content
– Java formally announced in 1995
– Now used to create web pages with interactive content,
enhance web servers, applications for consumer devices
(pagers, cell phones)...
1.9 Java Class Libraries
• Java programs
– Consist of pieces called classes
– Classes contain methods, which perform tasks
• Class libraries
– Also known as Java API (Applications Programming
Interface)
– Rich collection of predefined classes, which you can use
• Two parts to learning Java
– Learning the language itself, so you can create your own
classes
– Learning how to use the existing classes in the libraries
1.10 Other High-Level Languages
• A few other high-level languages have achieved
broad acceptance
– FORTRAN (FORmula TRANslator)
• Scientific and engineering applications
– COBOL (COmmon Business Oriented Language)
• Used to manipulate large amounts of data
– Pascal
• Intended for academic use
– BASIC
• Developed in 1965 as a simple language to help novices
1.11 Structured Programming
• Structured programming
– Disciplined approach to writing programs
– Clear, easy to test and debug, and easy to modify
– Pascal designed to teach structured programming in
universities
• Not used in industrial or commercial applications
• Multitasking
– Specifying that many activities run in parallel
– C and C++ only allow one activity to be performed at a time
– Java allows multithreading, where activities can occur in
parallel
1.13 Basics of a Typical Java Environment
• Java Systems
– Consist of environment, language, Java Applications
Programming Interface (API), Class libraries
• Java programs have five phases
– Edit
• Use an editor to type Java program
• vi or emacs, notepad, Jbuilder, Visual J++
• .java extension
– Compile
• Translates program into bytecodes, understood by Java
interpreter
• javac command: javac myProgram.java
• Creates .class file, containing bytecodes
(myProgram.class)
1.13 Basics of a Typical Java Environment
• Java programs have five phases (continued)
– Loading
• Class loader transfers .class file into memory
– Applications - run on user's machine
– Applets - loaded into Web browser, temporary
• Classes loaded and executed by interpreter with java command
java Welcome
• HTML documents can refer to Java Applets, which are loaded
into web browsers. To load,
appletviewer Welcome.html
– appletviewer is a minimal browser, can only interpret
applets
1.13 Basics of a Typical Java Environment
• Java programs have five phases (continued)
– Verify
• Bytecode verifier makes sure bytecodes are valid and do not
violate security
• Java must be secure - Java programs transferred over networks,
possible to damage files (viruses)
– Execute
• Computer interprets program one bytecode at a time
• Performs actions specified in program
– Program may not work on first try
• Make changes in edit phase and repeat
Phase 1
Editor
Disk
Program is created in
the editor and stored
on disk.
Phase 2
Compiler
Disk
Compiler creates
bytecodes and stores
them on disk.
Primary
Memory
Phase 3
Class Loader
Disk
Phase 4
Phase 5
Class loader puts
bytecodes in memory.
..
..
..
Primary
Memory
Bytecode Verifier
Interpreter
..
..
..
Primary
Memory
..
..
..
Bytecode verifier
confirms that all
bytecodes are valid
and do not violate
Java’s security
restrictions.
Interpreter reads
bytecodes and
translates them into a
language that the
computer can
understand, possibly
storing data values as
the program executes.
1.14 General Notes about Java and This
Book
• Java
– Powerful language
– Programming notes
• Clarity - Keep it Simple
• Portability - Java very portable, but it is an elusive goal
– Performance
• Interpreted programs run slower than compiled ones
– Compiling has delayed execution, interpreting executes
immediately
• Can compile Java programs into machine code
– Runs faster, comparable to C / C++
1.14 General Notes about Java and This
Book
• Just-in-time compiler
– Midway between compiling and interpreting
• As interpreter runs, compiles code and executes the program in
the machine language rather than reinterpreting.
• Not as efficient as full compilers
– A full compiler is being developed for Java
– Integrated Development Environment (IDE)
• Tools to support software development
• Several Java IDE's are as powerful as C / C++ IDE's
NEXT: * Object-Oriented Programming Concepts