Introduction to Java Programming - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

Introduction to Java Programming

Description:

You will be able to look down your nose at people who say they can use a ... It's trendy. It's useful and easy to use. It's the best language for the Internet ... – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 36
Provided by: StanO150
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Java Programming


1
Lecture 1
  • Introduction to Java Programming

2
Whats the big idea?
  • You will become a programmer.
  • You will make Windows and Web programs.
  • You will solve complex geographical problems.
  • You will be able to look down your nose at people
    who say they can use a computer when all they
    do is word process.
  • We shall, in short, become Über-Geeks, finely
    honed Code Warriors, the Elite of Geographers.
    Desired by the rich, admired by the poor.

3
What doesnt kill you makes you stronger
  • You will learn the patience of the Buddha.
  • You will learn that you are not a machine, youre
    a real live human boy/girl.

4
But first, an introduction
  • This lecture will introduce you to Java and how
    it works
  • What is Java?
  • Why Java for Geographers?
  • Brief History of Java
  • How does Java work?
  • Introduction to the Art of Programming
  • The course and next week

5
What is Java?
  • A language you write in simple text files that
    lets you program a computer to do stuff.
  • Famous as the language for programming on the
    Internet.
  • For some sad geekoids, its a way of life.
  • What can it do?
  • Make maps, sort out files, calculate models, form
    artificial intelligences, share stuff with other
    computers it can even make the coffee.

6
What does it look like?
  • int radius 10
  • int answer 2piradius
  • System.out.println(answer)
  • Code written in text files.
  • One or more files work together to make a program.

7
Terminology
  • Java Applications
  • Standalone programs that run on your desktop.
  • Java Applets
  • Programs that are run in your web browser.
  • More secure - cant do certain things like
    writing to your hard disk.
  • Java Script
  • Developed by Netscape for creating interactive
    web pages - not covered in this course.
  • http//en.wikipedia.org/wiki/Javascript
  • Java Beans
  • Bits of programs represented by jigsaw-like
    graphics you can stick together to make larger
    applications. Again, we wont cover these much.

8
  • What is Java?
  • Why Java for Geographers?
  • Brief History of Java
  • How does Java work?
  • Introduction to the Art of Programming
  • The course and next week

9
Why Java?
  • Its trendy
  • Its useful and easy to use
  • Its the best language for the Internet
  • Its Operating System (OS) independent
  • Its a good programming language (maybe better
    than C)
  • Because of all this, GIS manufacturers are using
    it more and more.
  • Knowing it will help you work with other
    programmers.
  • Our Alumni asked for it.

10
Skills Market http//mshiltonj.com/sm/
  • Dec 2006
  • c 5608
  • c 7298
  • delphi 150
  • Perl 4515
  • Python 755
  • VB 5534
  • Fortran 138
  • Java 15194

11
Portability versus Non-Portable Code
  • Java was mainly designed to be PORTABLE.
  • When a computer cost 5 million, the cost of the
    programmer (say 50K a year) was 1 of the
    capital cost
  • When the same computer costs 500 the
    programmers time is 100 times more expensive, a
    change in importance of 10,000 times

12
  • What is Java?
  • Why Java for Geographers?
  • Brief History of Java
  • How does Java work?
  • Introduction to the Art of Programming
  • The course and next week

13
A brief history of programming
  • 1930s Alan Turing first thought about
    programmable machines that had flexible uses.
  • 1940s First properly flexible computers
    programmed in binary First Generation
    Languages, for example 010110100110.
  • Early 1950s Second Generation Languages used
    simple codes to represent operations, like
    02A02 for 2 add 2.

14
Converting code to binary
  • A compiler is used to convert human language code
    into binary code once. The binary code can then
    be run as many times as you like.
  • An interpreter converts the human code into
    binary code every time you run the program.

15
A brief history of programming cont...
  • Mid 1950s Third generation languages in a
    human readable form, for example 2 add 2.
  • Fourth generation languages try to let people
    describe what they want to do, without
    complicating things with how theyre done.
  • Java is a Third generation Object Orientated
    Language.

16
Object Orientated Languages
  • At first programs were written so all the
    information about what to do was held in one
    file, and all the data in another.
  • Fast became a nightmare.
  • Object Orientated Languages build bits of code
    called Objects which can hold data and do
    specific things with it. Once theyre done, they
    pass the data on to another Object. Each Object
    has its own text file.

Example Objects
17
Example
  • Menu fileMenu new Menu (File)
  • MenuItem saveWeb
  • new MenuItem (Save as Web Page)
  • fileMenu.add(saveWeb)
  • MenuListener a new MenuListener(saveWeb)

18
Brief History of Java
  • Java was first released in 1995 as a platform
    independent and nicer version of C.
  • Java 1.1 was released early 1997
  • Faster.
  • Database access.
  • Networking improved.
  • Java 1.1 is the version that runs in most Web
    browsers.
  • Java 1.2 or Java 2
  • Slightly fancier.
  • Needs a plugin to work in most web browsers.
  • Java 1.5 / Java 5 (now 1.6 or Java 6)
  • A few additional bits you can turn on.

19
  • What is Java?
  • Why Java for Geographers?
  • Brief History of Java
  • How does Java work?
  • Introduction to the Art of Programming
  • The course and next week

20
How does Java work?
  • Java is two things a high-level programming
    language and a platform.
  • Programming language a set of instructions that
    tell a platform what to do with the hardware and
    what to calculate.
  • A platform the software and hardware that
    actually do the work and display stuff.

21
The Java Virtual Machine (JVM)
  • The Java Virtual Machine runs on top of the
    normal Operating System (OS) and pretends to be a
    whole new computer.
  • The Java language then runs inside the JVM,
    oblivious to the actual OS.
  • The most important part of the JVM is the
    Interpreter

22
The Interpreter
  • Most computer languages are compiled converted
    from human readable code to machine readable
    code.
  • When you compile a Java program, it gets
    converted into an intermediate language called
    Java bytecode that any JVM on any OS can
    understand. This is done once.
  • The interpreter does the final compilation into
    platform dependant code that the JVM sends to the
    OS. This is done each time the program is run.

23
Why the blazes would I want to know all that!?!?
  • The intermediate, platform independent code, the
    bytecode, is what you send out to people.
  • You need to make sure they have a JVM in order to
    run the Java bytecode.

24
What do I need to write Java?
  • You need a text editor and Suns Java
    Development Kit (JDK).
  • Text editors come with most OSs.
  • The JDK contains a JVM, some files to add extras
    to the core language, and applications like the
    compiler.
  • Its free, and youll see where to download it in
    the practical on Tuesday.

25
  • What is Java?
  • Why Java for Geographers?
  • Brief History of Java
  • How does Java work?
  • Introduction to the Art of Programming
  • The course and next week

26
Introduction to the Art of Programming
The key to programming is the art of describing
how to do very complicated things to a very
stupid computer in very simple steps. Together
these steps are called an algorithm, its a bit
like a recipe.
27
Swedish Lemon Angels
  • Beat 1 egg until foamy.
  • Add the 1/2 cup buttermilk (or 1/4 cup milk mixed
    with 1/4 cup vinegar) and 1/2 tsp vanilla and
    blend well.
  • Add 5 tsp baking soda, one teaspoon at a time,
    sprinkling it in and beating until the mixture is
    smooth and the consistency of light cream
  • Add 1 cup lemon juice all at once and blend into
    mixture. Stir, do NOT beat!

28
  • Scoop the mix from the bowl and spread it on a
    floured surface.
  • Sift 1 cup flour and 3/4 cup of sugar and work
    into the egg-lemon mixture.
  • Roll the dough out 1/32" thick, and with the tip
    of a sharp knife, cut the "angels" shapes and
    twist up the edges to form a shell-like curve
    about 3/8" high. Sprinkle on more sugar.
  • Brush each "angel" with melted butter.
  • Place angels one inch apart on an ungreased
    baking sheet and bake for 12 minutes or until
    golden.

29
How to calculate the mean of three numbers
  • Get 3 numbers.
  • Sum the numbers.
  • Add number 1 to number 2 and store the answer.
  • Add number 3 to the sum of the first 2 and store
    the answer.
  • Divide the sum by 3.
  • Print the result.

30
  • What is Java?
  • Why Java for Geographers?
  • Brief History of Java
  • How does Java work?
  • Introduction to the Art of Programming
  • The course and next week

31
The course
  • The first few weeks will look at the basics of
    the language.
  • Well then look at reading and writing files,
    making windows applications and web applets.
  • Well build a basic Artificial Intelligence.

32
Assessment
  • 40 Practicals.
  • 60 Final project.
  • The final project will be a program to work out
    some problem thinly related to geography.
  • Disease spread.
  • Strategic modelling.
  • Government coverups.
  • Titanic icebergs etc.etc.
  • The practicals will give you useful code for the
    projects.

33
Information
  • Recommended text books.
  • Things on the VLE
  • All the lectures, with extensive notes.
  • All the practicals.
  • The course outline.
  • A glossary of terms and links to programming
    encyclopaedias.
  • Useful links mentioned in the lectures.
  • Well visit the site in Practical One.

34
Practical
  • Tuesday 3.00 - 500 Masters lab.
  • Youll get instructions when you arrive.
  • In the meantime, by the practical please try and
    work out an algorithm to implement Pythagoras'
    theorem. Well be using this in the coming
    practicals.

35
Next Lecture
  • Well learn more about Object Orientated code.
  • We start programming.
Write a Comment
User Comments (0)
About PowerShow.com