2. About Me
●
Anton Keks
– Co-founder of Codeborne, an agile company
– Previously, team leader in Swedbank
– Strong believer in Open Source software
– Author of Angry IP Scanner
– Passionate traveler
– Likes motivated students :-)
● Contact
– anton @ azib.net
(Estonian, Russian, English)
Java course – IAG0040 Lecture 1
Anton Keks Slide 2
3. The Course
●
IAG0040
● “Programmeerimise erikursus II - Java”
“Special course in programming II - Java”
●
5.0 EAP / 3.5 AP
● In IASM curriculum, but anybody is welcome!
●
Can be substitued for "Programmeerimine II"
● The official site: http://java.azib.net/
Java course – IAG0040 Lecture 1
Anton Keks Slide 3
4. Prerequisites
●
It is recommended to
– know basics of OOP
(Object-oriented programming)
– be familiar with C and C++
● It is required to
– have a will to study and become a true
professional
Java course – IAG0040 Lecture 1
Anton Keks Slide 4
5. How to pass?
●
Do the homework (max 50 p)
● Pass the exam (max 50 p)
● Optionally participate in Robocode
competition (max 10 p extra)
● Standard rules for mark computation:
– finalPoints = homework + robocode + exam;
– mark = Math.min((finalPoints - 50) / 10, 5);
Java course – IAG0040 Lecture 1
Anton Keks Slide 5
6. Homework
●
The task is published on the official website
http://java.azib.net/wiki/Homework
(minor details may change)
●
Must work, have good design, quality code
●
Source code must be committed to Subversion
● Deadline is to be defined, close to the end of
the semester
Java course – IAG0040 Lecture 1
Anton Keks Slide 6
7. Robocode
●
Competition of robot tanks programmed in
Java
● Initiated by IBM
●
http://robocode.sourceforge.net/
● A fun way of learning Java language
● Competition will be organized
Java course – IAG0040 Lecture 1
Anton Keks Slide 7
8. Registration & Test
Course registration and test:
http://java.azib.net/questionnaire/
Java course – IAG0040 Lecture 1
Anton Keks Slide 8
9. Version Control
●
Historically, there were formalized processes
for revision control, e.g. in engineering, law,
business
– allowed to revert to an earlier version in case of
reaching a dead-end in design
– allowed to track authors and dates of changes
●
The earliest VCS for software engineering was
similar - just manual copying
Java course – IAG0040 Lecture 1
Anton Keks Slide 9
10. VCS History
●
1972: SCCS (Source Code Control System)
– was unique because of the 'weaves' (storage)
●
1980s: RCS (Revision Control System)
– for single files only, still used in specific cases
●
1986: CVS (Concurrent Versions System)
– initially shell script wrappers for RCS to manage
multiple files at once
●
2000: Subversion
– a YACC (Yet Another CVS Clone)
Java course – IAG0040 Lecture 1
Anton Keks Slide 10
11. Subversion
● A Version Control System (VCS)
● Is a 'better CVS'
● Allows many developers to work on the same code
base
● Supports development on different branches in
parallel
● Tracks modification history
● Allows restoration and rollbacks
● A lot of other possibilities!
Java course – IAG0040 Lecture 1
Anton Keks Slide 11
12. Subversion
●
Subversion repository is accessible using URLs
– http:// or https:// - WebDAV, https can be
proxied
– svn:// or svn+ssh:// - native protocol (and over
ssh)
– file:// - local repository
●
During the course we will use this one:
– https://svn.azib.net/java
Java course – IAG0040 Lecture 1
Anton Keks Slide 12
13. VCS/Subversion terminology
● repository - the place where Subversion holds all the files and their
revisions
● checkout - to retrieve (or sometimes update) files from the repository,
recreating exactly the same directory structure as on the server.
● commit - to finally put (or checkin) files or their modifications to the
server.
● revision - version of the repository state. Subversion assigns a single
sequential revision number to the whole commit.
● trunk - the main development tree in the repository.
● tag - a symbolic name, given to a specific state of the repository.
● branch - a parallel branch of modifications in the source code tree,
which can be modified and committed independently from the trunk.
Java course – IAG0040 Lecture 1
Anton Keks Slide 13
14. Repository layout
●
Standard top-level directories
– trunk – the main development tree
– branches – for parallel development
– tags – labeled states of the tree (released versions)
– all of them contain the same project structure
inside
● Branching is done via 'svn copy' command
– copies are cheap – only changes are stored
– switch to another branch via 'svn switch'
Java course – IAG0040 Lecture 1
Anton Keks Slide 14
15. Project structure
●
Most Java projects have the following top-
level elements:
– src - main Java source code (deliverable)
– test - automated tests (also written in Java)
– lib - used external libraries (jar files)
– build.xml - Ant build script, used for continuous
integration
Java course – IAG0040 Lecture 1
Anton Keks Slide 15
16. Java History
●
Initially developed as an embedded
language for interactive TV consoles,
initially named Oak
●
In 1995 began to target the Internet.
Renamed to Java
●
Applets were the “killer app”
●
Servlets helped to survive
●
Now the most successful and
dominating programming language
Java course – IAG0040 Lecture 1
Anton Keks Slide 16
17. Most used in...
●
Server-side enterprise applications
● JavaME/CLDC – mobile apps/games
● Blue-Ray
● Google Android mobile platform
●
Some cross-platform desktop software
Java course – IAG0040 Lecture 1
Anton Keks Slide 17
18. Latest major news
●
Sun Microsystems acquired by Oracle - 2010
● Java became open-source (OpenJDK) - 2007
● Java 1.6 released in November 2006
● Java 1.5 discontinued in November 2009
●
Development of Java 1.7 is still in progress
Java course – IAG0040 Lecture 1
Anton Keks Slide 18
19. 3-letter acronyms
●
JDK = Java Development Kit
used to write Java programs
● JRE = Java Runtime Environment
used to run compiled Java programs
●
JVM = Java Virtual Machine
is a part of both JDK and JRE
●
Java = language + JVM + API
Java course – IAG0040 Lecture 1
Anton Keks Slide 19
20. Java versions
●
Java 1.0 – first public release
●
Java 1.1 – JIT, better AWT, better unicode support
●
Java 1.2 – first Java 2 release, Collections, JIT
● Java 1.3 – dynamic proxies
● Java 1.4 – XML, Regular Expressions, assertions
●
Java 1.5 – aka Java 5 – lots of new language features
● Java 1.6 – aka Java 6 – scripting, better desktop
●
Java 1.7 & 1.8 – many new language features are
planned
Java course – IAG0040 Lecture 1
Anton Keks Slide 20
21. Java flavors
●
Java SE – standard edition (J2SE)
●
Java EE – enterprise edition (J2EE)
●
Java ME – micro/mobile edition (J2ME)
● Java Card – for smart cards
●
Sun Java – official
● IBM Java SDK
● GNU Java – gcj & gij
● Icedtea – early releases of OpenJDK 1.7
● and others
Java course – IAG0040 Lecture 1
Anton Keks Slide 21
22. The progress of abstraction
●
Logic ICs, hardware
● CPU, instructions
● Assembly language
● Procedural languages: Fortran, Pascal, C
●
Problem modeling languages: LISP, LabView
●
Object-oriented languages: Smalltalk, C++
●
Java and JVM (Java Virtual Machine)
Java course – IAG0040 Lecture 1
Anton Keks Slide 22
23. Java classification
●
Java language is
– general-purpose
– object-oriented
– static
– strongly typed
– memory safe
– compiled, but bytecode-interpreted
Java course – IAG0040 Lecture 1
Anton Keks Slide 23
24. Main OOP concepts
●
Everything is an object
● A program is a bunch of objects telling each
other what to do by sending messages
●
Each object has its own memory made up of
other objects
● Every object has a type
●
All objects of a particular type can receive the
same messages
●
An object has state, behavior and identity
Java course – IAG0040 Lecture 1
Anton Keks Slide 24
25. Java vs C++
● Java is loosely based on C++, but is more “pure”
● All objects are on the heap
● No pointers, only references
● Garbage collection
● Simplified constructs
● “Root” object: java.lang.Object
●
Checked exceptions
●
No multiple inheritance, but interfaces
● No operator overloading, no preprocessor, no macros
● Packages instead of namespaces
Java course – IAG0040 Lecture 1
Anton Keks Slide 25
26. Hello World time!!!
public class HelloWorld {
public static void main(String[] args) {
System.out.println(“Hello World!”);
}
}
● Put it into the HelloWorld.java file
● Compile with javac HelloWorld.java
(you will get a binary file HelloWorld.class)
●
Run with java HelloWorld
(means run class HelloWorld, by default look for it in the current directory)
Java course – IAG0040 Lecture 1
Anton Keks Slide 26
27. IntelliJ IDEA
●
The “smartest” Java IDE around
● Now has a free Community Edition
– Syntax highlighting
– Code completion, suggestions, templates
– Refactorings
– Integrated Subversion support
● With practice your productivity can increase
multiple times (learn shortcut keys)
Java course – IAG0040 Lecture 1
Anton Keks Slide 27
28. Initial Setup
IntelliJ IDEA and Subversion are our main tools
during this course, prepare yourself using this
guide:
http://java.azib.net/wiki/Setup
Java course – IAG0040 Lecture 1
Anton Keks Slide 28
29. Continuous integration
●
Regular automated builds of the software (e.g.
after each commit)
– the whole program is recompiled
– automated tests are run
– documentation is generated
– software is packaged and therefore ready to run
Java course – IAG0040 Lecture 1
Anton Keks Slide 29
30. Benefits of CI
●
Provides quick feedback to developers
●
Reduces wasted time of the team due to broken code
●
Helps to find integration problems and failed tests
early
● The latest builds are always runnable and testable by
e.g. customers
● Hudson is one of the tools often used for this purpose
– http://java.azib.net/hudson
– it will send you automatic mails if you are guilty!
Java course – IAG0040 Lecture 1
Anton Keks Slide 30
31. Classes
●
Basically, all you do in Java is define classes
– everything else is inside of them:
fields, methods, code instructions
●
Class names are in “CamelCase”
– HelloWorld, String, BigDecimal
● class MyClass { /*body here*/ }
● Public classes must be defined in files with
same names
Java course – IAG0040 Lecture 1
Anton Keks Slide 31
32. Packages
●
Classes generally reside in packages
●
Specified in the beginning of the file:
– package net.azib.java;
– names usually start with domain name of the author
– package is optional (but highly recommended)
●
Each dot-separated token represents a directory
– net.azib.java.HelloWorld class should reside in
net/azib/java/HelloWord.class file on the disk
● Classes are referenced by their full names unless
imported: import net.azib.java.HelloWorld;
Java course – IAG0040 Lecture 1
Anton Keks Slide 32