Java Course 1: Introduction
Upcoming SlideShare
Loading in...5
×
 

Java Course 1: Introduction

on

  • 1,521 views

Lecture 1 from the IAG0040 Java course in TTÜ.

Lecture 1 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course

Statistics

Views

Total Views
1,521
Views on SlideShare
1,521
Embed Views
0

Actions

Likes
3
Downloads
51
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Java Course 1: Introduction Java Course 1: Introduction Presentation Transcript

  • Java course - IAG0040 IntroductionAnton Keks 2011
  • 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 1Anton Keks Slide 2
  • 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 1Anton Keks Slide 3
  • 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 professionalJava course – IAG0040 Lecture 1Anton Keks Slide 4
  • 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 1Anton Keks Slide 5
  • 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 semesterJava course – IAG0040 Lecture 1Anton Keks Slide 6
  • 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 organizedJava course – IAG0040 Lecture 1Anton Keks Slide 7
  • Registration & Test Course registration and test: http://java.azib.net/questionnaire/Java course – IAG0040 Lecture 1Anton Keks Slide 8
  • 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 copyingJava course – IAG0040 Lecture 1Anton Keks Slide 9
  • 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 1Anton Keks Slide 10
  • 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 1Anton Keks Slide 11
  • 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/javaJava course – IAG0040 Lecture 1Anton Keks Slide 12
  • 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 1Anton Keks Slide 13
  • 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 switchJava course – IAG0040 Lecture 1Anton Keks Slide 14
  • 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 integrationJava course – IAG0040 Lecture 1Anton Keks Slide 15
  • 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 languageJava course – IAG0040 Lecture 1Anton Keks Slide 16
  • Most used in... ● Server-side enterprise applications ● JavaME/CLDC – mobile apps/games ● Blue-Ray ● Google Android mobile platform ● Some cross-platform desktop softwareJava course – IAG0040 Lecture 1Anton Keks Slide 17
  • 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 progressJava course – IAG0040 Lecture 1Anton Keks Slide 18
  • 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 + APIJava course – IAG0040 Lecture 1Anton Keks Slide 19
  • 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 plannedJava course – IAG0040 Lecture 1Anton Keks Slide 20
  • 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 othersJava course – IAG0040 Lecture 1Anton Keks Slide 21
  • 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 1Anton Keks Slide 22
  • Java classification ● Java language is – general-purpose – object-oriented – static – strongly typed – memory safe – compiled, but bytecode-interpretedJava course – IAG0040 Lecture 1Anton Keks Slide 23
  • 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 identityJava course – IAG0040 Lecture 1Anton Keks Slide 24
  • 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 namespacesJava course – IAG0040 Lecture 1Anton Keks Slide 25
  • 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 1Anton Keks Slide 26
  • 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 1Anton Keks Slide 27
  • Initial Setup IntelliJ IDEA and Subversion are our main tools during this course, prepare yourself using this guide: http://java.azib.net/wiki/SetupJava course – IAG0040 Lecture 1Anton Keks Slide 28
  • 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 runJava course – IAG0040 Lecture 1Anton Keks Slide 29
  • 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 1Anton Keks Slide 30
  • 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 namesJava course – IAG0040 Lecture 1Anton Keks Slide 31
  • 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 1Anton Keks Slide 32